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的更多相关文章

  1. Berkeley 四种产品如何选择?

    Berkeley 四种产品如何选择? 四种产品综览 Berkeley 可供选择的四款产品: DS: 简单的.支持单写单读的数据存储:支持高并发,多进程同时读操作:不支持锁,这就意味着当程序在进行更新和 ...

  2. ABAP程序执行效率和优化 ABAP Performance Examples

    一.             SQL Interface1.         Select ... Where vs. Select + Check用Select … Where语句效率比Select ...

  3. Awesome Hadoop

    A curated list of amazingly awesome Hadoop and Hadoop ecosystem resources. Inspired by Awesome PHP,  ...

  4. EOS踩坑记

    [EOS踩坑记] 1.每个account只能更新自己的contract,即使两个account的秘钥相同,也不允许. 如下,使用alice的权限来更新james的contract.会返回 Missin ...

  5. BerkeleyDB java的简单使用

    关于BerkeleyDB的有点和优点,列在以下 JE offers the following major features: Large database support. JE databases ...

  6. MySQL、HBase、ES的特点和区别

    MySQL:关系型数据库,主要面向OLTP,支持事务,支持二级索引,支持sql,支持主从.Group Replication架构模型(本文全部以Innodb为例,不涉及别的存储引擎). HBase:基 ...

  7. [AlwaysOn Availability Groups]排查:Primary上的修改无法在Secondary体现

    排查:Primary上的修改无法在Secondary体现 客户端进程在primary上修改成功,但是在Secondary上却无法看到修改结果.这个case假设你的可用性组有同步的健康问题.很多情况下这 ...

  8. Visual Studio 2015 Pre Secondary Installer 在哪里

    安装vs2015 pre后,会自动打开Secondary Installer, 用于Cross Platform的移动开发框架,包括Cordova插件.若安装失败,启动程序位置: "D:\P ...

  9. Secondary NameNode:的作用?

    前言 最近刚接触Hadoop, 一直没有弄明白NameNode和Secondary NameNode的区别和关系.很多人都认为,Secondary NameNode是NameNode的备份,是为了防止 ...

随机推荐

  1. 温度转换-java

    java 温度转换 题目内容: 写一个将华氏温度转换成摄氏温度的程序,转换的公式是: °F = (9/5)*°C + 32 其中C表示摄氏温度,F表示华氏温度. 程序的输入是一个整数,表示华氏温度.输 ...

  2. [LeetCode&Python] Problem 458. Poor Pigs

    There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. Th ...

  3. Python全栈之路----函数----局部变量

    全局变量是定义在函数外部以及代码的变量,全局能用. 局部变量就是定义在函数里的变量,只能在局部生效. 在函数内部,可以引用全局变量. 如果全局和局部都有一个名字相同的变量,在函数内会优先调用函数内的局 ...

  4. 软件工程 week 03

    一.效能分析 1.作业地址:https://edu.cnblogs.com/campus/nenu/2016CS/homework/2139 2.git地址:https://git.coding.ne ...

  5. Yii2事件驱动的运行机制

    最近一段时间正在作个一个项目,这个项目会系统逻辑比较复杂,使用PHP Yii2,使用事件驱动机制进行研发,下面就最近研究事件驱动机制的使用作以下总结: 流程如下: 1.要创建含有事件注入的类,一般这样 ...

  6. 如何用node命令和webpack命令传递参数 转载

    1. 比如在项目中我们的publicPath需要根据服务器环境的变化而变化,这时我们会写一个配置文件,在webpack.config.js中读取,可以 如何才能 取到变量呢? 这里介绍一种方法: 如果 ...

  7. github 的ssh key

    一.输入cd ~/.ssh——回车(看你是否有了ssh key 密钥): 二.若无密匙,输入ssh-keygen -t rsa -C "your email"——直接回车,回车,跟 ...

  8. Spring IOC 相关的面试题

    Spring最基础的部分就是IOC,对IOC的理解程度从某个方面代表着你对Spring  的理解程度,看了网上的一些面试题,针对Spring IOC相关的重点是下面几个: 1.Spring中Bean ...

  9. 浅谈JavaScript函数重载

    上个星期四下午,接到了网易的视频面试(前端实习生第二轮技术面试).面了一个多小时,自我感觉面试得很糟糕的,因为问到的很多问题都很难,根本回答不上来.不过那天晚上,还是很惊喜的接到了HR面电话.现在HR ...

  10. 使用Intellij搭建Servlet开发环境

    https://blog.csdn.net/yhao2014/article/details/45740111 使用Tomcat 9时,必须使用jre 1.8,否则会出现Unable to ping ...