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的备份,是为了防止 ...
随机推荐
- 解决Myeclipse通过svn导入项目后,项目直接报错问题
在使用Myeclipse2015通过SNV导入项目后,项目直接报错,如下图: 点开后报错详细信息如下: Multiple markers at this line - The type java.la ...
- SpringCloud使用Feign调用服务时,@FeignClient注解无法使用
关于解决这个问题的理论根源传送门:https://blog.csdn.net/alinyua/article/details/80070890我在这里只提供解决方案 0. 结论和解决方案 Spring ...
- PHP 打开已有图片进行编辑
<?php header("content-type:image/jpeg");//表明请求页面的内容是jpeg格式的图像 即当前页面会以图片的新式展示 去掉这行就可以显示正 ...
- BSGS模板(慢速)
//author Eterna #define Hello the_cruel_world! #pragma GCC optimize(2) #include<iostream> #inc ...
- expect脚本实现ssh自动登录
1:简单的实现ssh登录 #!/usr/bin/expect set ip "10.0.0.142" set user "root" set password ...
- Linux which命令详解
Linux which命令 Linux which命令用于查找文件. which指令会在环境变量$PATH设置的目录里查找符合条件的文件 用法: which [options] [--] COMMAN ...
- 串口接收端verilog代码分析
串口接收端verilog代码分析 `timescale 1ns / 1ps ////////////////////////////////////////////////////////////// ...
- 这台计算机上缺少此项目引用的 NuGet 程序包,DotNetCompilerPlatform
严重性 代码 说明 项目 文件 行 禁止显示状态错误 这台计算机上缺少此项目引用的 NuGet 程序包.使用“NuGet 程序包还原”可下载这些程序包.有关更多信息,请参见 http://go.mic ...
- Python3 练习2 列表和字典练习
找出列表list中大于100的值,给字典dic的k1键,小于等于100的值,给字典dic的k2键 ''' 提示:创建字典的两种方式 ex: ''' v1 = [2,3,4,5,] v2 = 88 di ...
- git与github区别与简介
From: https://blog.csdn.net/skyxmstar/article/details/65631658 git和github是两个完全不同的概念. git 是一个版本管理工具,是 ...