EOSIO / eos

An open source smart contract platform
https://developers.eos.io/manuals/eos
MIT License
11.28k stars 3.6k forks source link

How to get table sorted by secondary index using cleos #2983

Closed sim31 closed 6 years ago

sim31 commented 6 years ago

cleos get table command has a -k option which supposed to do what I want. But it does not seem to work. I'm testing this with this contract: https://github.com/sim31/timeos

If I do cleos get table -k reverse timeos user timestamp it returns rows in usual order by primary key. I can tell indexing itself in contract is working, because my getts action prints rows in the right (reverse) order according to index.

FortisFortuna commented 6 years ago

Please include this. It is needed for eosjs / Scatter and pulling data remotely with the get_table_rows API function. Another issue: if I wanted to execute something like WHERE column1 = 1234, i would have to do this: --lower "1233" --upper "1234" --key "column1indexname".

k26dr commented 6 years ago

I'm having the same issue. Secondary index ranges don't work in cleos

samkazemian commented 6 years ago

Ya, this is desperately needed for advanced querying. If there is another workaround for the time being, it would be helpful to be pointed to it.

taokayan commented 6 years ago

4053

mjshin82 commented 6 years ago

image

"get all records with secondary key" API is needed. A client may want to get all Bob's records. For that, there is no other way to separate scope in this 1.0.x version. However, this method charges the user.

taokayan commented 6 years ago

you can set the "limit" parameter in get table. It won't charge the user because "get table" only read the content from one node.

andriantolie commented 6 years ago

Check this one https://github.com/EOSIO/eos/pull/4053, you can use --index and --key-type on v1.1.0 to achieve it