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的备份,是为了防止 ...
随机推荐
- mql初学事物和视图
1.概念:一条或者多条sql语句的集合! 事务:就是一堆操作的集合,他们同生共死.要么都执行成功,要么都执行失败 2.事务的特性 ACID A:原子性 完整的,不可分割的 原子性 (Atomicity ...
- 初窥async,await
首先是一道今日头条的面试题:(听说是今日头条的并且已经烂大街了) async function async1() { console.log( 'async1 start' ) await async ...
- css文本是否换行
关于文本换行有三个属性: white-space word-break word-wrap white-space normal 默认.空白会被浏览器忽略 pre 空白会被浏览器保留.其行为方式类似 ...
- (32)forms组件(数据校验)
forms组件的用处 1.就是用来做数据校验的 2.渲染页面 3.渲染错误信息(和局部刷新同效果) 数据校验 要使用forms组件必须要写一个类继承forms组件 urls.py from bbs01 ...
- java 程序编译和运行过程
java整个编译以及运行的过程相当繁琐,我就举一个简单的例子说明: Java程序从源文件创建到程序运行要经过两大步骤: 1.源文件由编译器编译成字节码(ByteCode): 2.字节码由java虚拟机 ...
- Spring Cloud(Dalston.SR5)--Zuul 网关
我们使用 Spring Cloud Netflix 中的 Eureka 实现了服务注册中心以及服务注册与发现:而服务间通过 Ribbon 或 Feign 实现服务的消费以及均衡负载:使用Hystrix ...
- 黄聪:如何扩展Chrome DevTools来获取页面请求
1. Chrome DevTools Extension 熟悉React的同学,可能对React Developer Tools并不陌生, 刚看到的时候,我也觉得很神奇, 因为React De ...
- linux命令行命令
Linux命令行编辑快捷键: history 显示命令历史列表 ↑(Ctrl+p) 显示上一条命令 ↓(Ctrl+n) 显示下一条命令 !num 执行命令历史列表的第num条命令 !! 执行上一条命令 ...
- Kafka 配置安装
1.从官网下载安装包 http://kafka.apache.org/downloads2.上传到01虚拟机,解压3.进入安装目录下的config目录4.对server.properties进行配置 ...
- .net 连接 Oracle 可能需要配置
D:\Program Files (x86)\Oracle Developer Tools for VS2013\network\admin\tnsnames.ora