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的备份,是为了防止 ...
随机推荐
- 关于windows下的makefile学习
文中部分引用自:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=408225 windows下makefile环境配置见于:http ...
- django中向用户发送邮件信息
发送邮件来让用户激活,因此,邮件中需要包含用户信息.但用户信息需要加密才可以.因此加密采用的是itsdangerous中的TimedJSONWebSignatureSerializer. 参考链接:h ...
- Python全栈之路----数据类型—列表
1.列表是一个数据的集合,集合内可以放任何数据类型,可对集合进行方便的增删改查操作.列表里面的数可以重复. L1 = [ ] #定义空列表 L2 = [ 'a' , 'b' , 'c' , 'd' ] ...
- 1.Python
一.Python基础:1.第一句python文件后缀名:文件后缀名是.py2.两种执行方式:(1)把文件地址交给python解释器,python解释器去找到这个文件读到内存执行(2)进入解释器:解释器 ...
- CodeForces - 13E
Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for on ...
- 【java多线程】队列系统之说说队列Queue
转载:http://benjaminwhx.com/2018/05/05/%E8%AF%B4%E8%AF%B4%E9%98%9F%E5%88%97Queue/ 1.简介 Queue(队列):一种特殊的 ...
- nginx添加一个站点
server { listen ; server_name demo.abc.com ; root /Users/pa200318/demo.cp.com/trunk; index index.php ...
- jenkins 结合 jmeter 的报告篇
背景:实现jmeter每30分钟执行一次,运行系统中所有接口或者性能脚本或者后续更可以由系统部署来触发建构执行 1.配置jmeter测试环境,注意修改Jmeter的bin目录下jmeter.prope ...
- Spring Cloud(Dalston.SR5)--Zuul 网关-过滤器
Spring Cloud 为 HTTP 请求的各个阶段提供了多个过滤器,这些过滤器的执行顺序由各自提供的一个 int 值决定,提供的值越小则优先级越高,默认的过滤器及优先级如下: 自定义过滤器 在默认 ...
- 量化分析v1
量化分析v1 # -*- coding: utf-8 -*- """ Created on Wed Apr 11 10:13:32 2018 @author: chens ...