Secondary Indices
【Secondary Indices】
EOSIO has the ability to sort tables by up to 16 indices. A table's struct cannot be modified when it has data in it. \
1、添加第二列索引 member 和 getter。
The secondary index needs to be numeric field, so a uint64_t was chosen for the age variable

2、Add secondary index to `addresses` table configuration
typedef eosio::multi_index<"people"_n, person,
indexed_by<"byage"_n, const_mem_fun<person, uint64_t, &person::get_secondary_1>>
> address_index;
1) indexed_by 是一个 struct.
2) first parameter set name of index as "byage"
3) the second type parameter as a function call operator should extract a const value as an index key.
3、compile & deploy
eosio-cpp -o addressbook.wasm addressbook.cpp --abigen cleos set contract addressbook /home/ubuntu/contracts/addressbook
4、Test
cleos push action addressbook upsert '["alice", "alice", "liddell", 9, "123 drink me way", "wonderland", "amsterdam"]' -p alice@active cleos push action addressbook upsert '["bob", "bob", "is a guy", 49, "doesnt exist", "somewhere", "someplace"]' -p bob@active
查看一下插入结果,注意--upper 10 是指定上限,即只查看索引值小于10的row.
cleos get table addressbook addressbook people --upper \
--key-type i64 \
--index
上面命令会看到结果

参考:https://developers.eos.io/eosio-home/docs/secondary-indices
Secondary Indices的更多相关文章
- Berkeley 四种产品如何选择?
Berkeley 四种产品如何选择? 四种产品综览 Berkeley 可供选择的四款产品: DS: 简单的.支持单写单读的数据存储:支持高并发,多进程同时读操作:不支持锁,这就意味着当程序在进行更新和 ...
- ABAP程序执行效率和优化 ABAP Performance Examples
一. SQL Interface1. Select ... Where vs. Select + Check用Select … Where语句效率比Select ...
- Awesome Hadoop
A curated list of amazingly awesome Hadoop and Hadoop ecosystem resources. Inspired by Awesome PHP, ...
- EOS踩坑记
[EOS踩坑记] 1.每个account只能更新自己的contract,即使两个account的秘钥相同,也不允许. 如下,使用alice的权限来更新james的contract.会返回 Missin ...
- BerkeleyDB java的简单使用
关于BerkeleyDB的有点和优点,列在以下 JE offers the following major features: Large database support. JE databases ...
- MySQL、HBase、ES的特点和区别
MySQL:关系型数据库,主要面向OLTP,支持事务,支持二级索引,支持sql,支持主从.Group Replication架构模型(本文全部以Innodb为例,不涉及别的存储引擎). HBase:基 ...
- [AlwaysOn Availability Groups]排查:Primary上的修改无法在Secondary体现
排查:Primary上的修改无法在Secondary体现 客户端进程在primary上修改成功,但是在Secondary上却无法看到修改结果.这个case假设你的可用性组有同步的健康问题.很多情况下这 ...
- Visual Studio 2015 Pre Secondary Installer 在哪里
安装vs2015 pre后,会自动打开Secondary Installer, 用于Cross Platform的移动开发框架,包括Cordova插件.若安装失败,启动程序位置: "D:\P ...
- Secondary NameNode:的作用?
前言 最近刚接触Hadoop, 一直没有弄明白NameNode和Secondary NameNode的区别和关系.很多人都认为,Secondary NameNode是NameNode的备份,是为了防止 ...
随机推荐
- [LeetCode&Python] Problem 844. Backspace String Compare
Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...
- 基于VM上的Ubuntu16.04如何和window界面进行复制,粘贴工作
1.卸载VMware tools: sudo apt-get autoremove open-vm-tools 2.安装界面版VMware tools. sudo apt-get install op ...
- 使用samba或NFS实现文件共享
- Python开发 基礎知識 2.變量 ( *arg, **kwargs )
變量 *args 和 **kwargs ( *和**為本體,名稱為通俗的名稱約定 ) *args 用於函式定義. 可將不定數量的參數傳遞給一個函數,傳入函式的引數,會先以Tuple物件收集,再設定給參 ...
- 依据Axis2官网的高速入门英文文档总结
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/ksdb0468473/article/details/29918027 首先在Eclipse中创建一 ...
- Centos7安装mysql5.6.29shell脚本
创建脚本mysql.sh,直接运行sh mysql.sh #!/bin/bash if [ -d /software ] ;then cd /software else mkdir /software ...
- 用C自撸apache简易模块,搭建图片处理服务器。
写C是个撸sir /* ** mod_acthumb.c -- Apache sample acthumb module ** [Autogenerated via ``apxs -n acthumb ...
- 【python】参数中的*args和**kwargs
转自https://www.cnblogs.com/xuyuanyuan123/p/6674645.html#undefined 多个实参,放到一个元组里面,以*开头,可以传多个参数:**是形参中按照 ...
- workerman相关
(1)workerman linxu 内核优化 http://doc.workerman.net/315302 (2)workerman 安装环境配置 http://doc.workerman.ne ...
- Ubuntu 16.04 安装Mysql数据库
系统环境 Ubuntu 16.04; 安装步骤 1.通过以下环境安装mysql服务端与客户端软件 sudo apt-get install mysql-server apt-get isntall m ...