EOSIO / history-tools

EOSIO History Tools
https://eosio.github.io/history-tools/
MIT License
64 stars 45 forks source link

query descending order #80

Open Thomas55777 opened 4 years ago

Thomas55777 commented 4 years ago

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 commented 4 years ago

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

tbfleming commented 4 years ago

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

Thomas55777 commented 4 years ago

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?

tbfleming commented 4 years ago

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.

Thomas55777 commented 4 years ago

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

tbfleming commented 4 years ago

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 commented 4 years ago

The kv tables have similarly-named methods.

Thomas55777 commented 4 years ago

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?

tbfleming commented 4 years ago

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.

Thomas55777 commented 4 years ago

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?

tbfleming commented 4 years ago

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:

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.

baxterjfinch commented 4 years ago

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?