history-tools icon indicating copy to clipboard operation
history-tools copied to clipboard

query descending order

Open Thomas55777 opened this issue 4 years ago • 12 comments

What is the proper way to query in descending order: from newest to oldest? I tried to check /v1/history/get_actions to see how that was done and even those results are returned ascending order: from oldest to newest.

Thomas55777 avatar Apr 09 '20 20:04 Thomas55777

Any update on this. This is still a problem for me. Thank you

Thomas55777 avatar May 11 '20 15:05 Thomas55777

We stopped development on the legacy /v1/history api.

tbfleming avatar May 11 '20 16:05 tbfleming

Ok thank you for the reply, but the question was not specific to /v1/history but more of a broader question. How can you query in descending order?

Thomas55777 avatar May 11 '20 18:05 Thomas55777

When writing a wasm-ql query handler (C++): both the old-style CDT table API and the new-style CDT KV table API provide support for C++ reverse iteration.

tbfleming avatar May 11 '20 19:05 tbfleming

I would be very appreciative of an example. I have looked and cannot find one anywhere.

Thomas55777 avatar May 11 '20 19:05 Thomas55777

multi_index's rbegin() and rend() methods. I don't know of any examples, but they behave similar to the C++ standard containers' rbegin() and rend() methods:

https://developers.eos.io/manuals/eosio.cdt/latest/classeosio_1_1multi__index#function-rbegin

tbfleming avatar May 11 '20 19:05 tbfleming

The kv tables have similarly-named methods.

tbfleming avatar May 11 '20 19:05 tbfleming

I dont understand how that link applies. I have been struggling with this for a while, and this is a common enough requirement that others will also benefit from some instruction of how to do this.

Am I meant to be modifying database.hpp somewhere with the rbegin() and rend() methods?

Thomas55777 avatar May 11 '20 20:05 Thomas55777

database.hpp is obsolete. I don't believe I got around to adding reverse iteration support to it before dumping that API and switching to the 2 CDT table APIs.

tbfleming avatar May 11 '20 20:05 tbfleming

any examples of 2 CDT table APIs?

Also I take back my reference to database.hpp. My question is a broader, How can this be done?

Thomas55777 avatar May 11 '20 20:05 Thomas55777

See the top of the readme on this branch: https://github.com/EOSIO/history-tools/tree/idea

No examples have made it into the public repos yet for the current direction. The basic idea of the current direction:

  • nodeos on the eos develop branch supports actions returning values. A wasm-ql query is just an action on a contract that returns a result without mutating data.
  • both nodeos and rodes can run wasm-ql queries.
  • rodeos adds parallel execution and filter wasm support.

If you know how to access a table from within an action, you already know how to write a query. Note that hard forks have to be activated and there's a lot still missing.

tbfleming avatar May 11 '20 20:05 tbfleming

I'm building out wasm-ql queries using the database.hpp and using them in a custom block explorer. Is there any re-usability from the soon-to-be deprecated wasm-ql/database.hpp stuff with regard to the new method (rodeos?) or is the method too different for any sort of refactorization?

baxterjfinch avatar May 16 '20 03:05 baxterjfinch