eos icon indicating copy to clipboard operation
eos copied to clipboard

get_table_rows with secondary key

Open mamidi1211 opened this issue 8 years ago • 3 comments

using get_table_rows http api how can we filter/ query using secondary primary key ?

mamidi1211 avatar Sep 04 '18 12:09 mamidi1211

curl -X POST https://kylin.eoscanada.com/v1/chain/get_table_rows -d '{"json":true,"code":"cancancan345","scope":"cancancan345","table":"vote", "index_position":2,"key_type":"i128","lower_bound":"0x0000000000000000D0F2A472A8EB6A57","upper_bound":"0xFFFFFFFFFFFFFFFFD0F2A472A8EB6A57"}'

If you omit the both lower_bound and upper_bound, results are sorted according to the secondary index key.

See https://github.com/eoscanada/eosio.forum/blob/master/include/forum.hpp#L110 for the secondary indexes definitions.

So, the answer is yes. This issue should closed IMO.

maoueh avatar Sep 04 '18 20:09 maoueh

Also note that if your secondary index type is name, you can use a name as the key instead of an hex string, something like: "lower_bound":"abc","upper_bound":"def".

Also, for complex keys, you must an HEX string in little endian format.

maoueh avatar Sep 04 '18 21:09 maoueh

see #3695

taokayan avatar Sep 05 '18 08:09 taokayan