Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/cmd console use indexer to query #469

Closed
wants to merge 2 commits into from

Conversation

jingchen2222
Copy link
Collaborator

@jingchen2222 jingchen2222 commented Jun 5, 2023

REsolve #467

Change

  • use indexer-sdk instead of store-sdk to query document/database

Future work

  • support subscribe API in indexer-node
  • onboard JS SDK and console/clinet with indexer-subscribe

Demo

❯ ./target/debug/db3 console                                                                   ─╯

██████╗ ██████╗ ██████╗
██╔══██╗██╔══██╗╚════██╗
██║  ██║██████╔╝ █████╔╝
██║  ██║██╔══██╗ ╚═══██╗
██████╔╝██████╔╝██████╔╝
╚═════╝ ╚═════╝ ╚═════╝
@db3.network🚀🚀🚀
db3>-$ init
 address                                    | scheme
--------------------------------------------+-----------
 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | secp256k1
db3>-$ new-db
 database address                           | mutation id
--------------------------------------------+----------------------------------------------
 0xef32c065a274503a1f3dff17abaf574ea93b87cf | acZXzaJYaVMgAKthPLuXnx8byiZ7C83jn6ic9tDprZU=
db3>-$ new-collection --addr 0xef32c065a274503a1f3dff17abaf574ea93b87cf --name books --index '{"id":1,"name":"idx1","fields":[{"field_path":"name","value_mode":{"Order":1}}]}' --index '{"id":2,"name":"idx2","fields":[{"field_path":"age","value_mode":{"Order":1}}]}'
send add collection done!
 mutation_id
----------------------------------------------
 MKg7USw0w1VUlRZKfNC2jMLF6nnj3tHb39x6DpjCcRU=
db3>-$ new-doc --addr 0xef32c065a274503a1f3dff17abaf574ea93b87cf --collection-name books --documents '{"name": "John Doe","age": 43,"phones": ["+44 1234567","+44 2345678"]}'
send add document done
 mutation id
----------------------------------------------
 nWU8DjJq6h6wosTKvCKttuh0Y9VAIfiXxOtb4fN/Vrg=
db3>-$ new-doc --addr 0xef32c065a274503a1f3dff17abaf574ea93b87cf --collection-name books --documents '{"name": "Bill","age": 44,"phones": ["+44 1234567","+44 2345678"]}'
send add document done
 mutation id
----------------------------------------------
 ZwKF0HdZETrq0M6GjmVHN5bFAYzUO0uv9/5RyJBnvnw=
db3>-$ new-doc --addr 0xef32c065a274503a1f3dff17abaf574ea93b87cf --collection-name books --documents '{"name": "Bill","age": 46,"phones": ["+44 1234567","+44 2345678"]}'
send add document done
 mutation id
----------------------------------------------
 jRk5P/TdjXJX1D2YHfW/5Yfm8qybuWlCrlCQTL4Uz6I=
db3>-$ show-doc --addr 0xef32c065a274503a1f3dff17abaf574ea93b87cf --collection-name books
 id_base64                            | owner                                      | document                                                                                                                  | mutation_id
--------------------------------------+--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------
 AQAAAAAAAAB6AAEAAQAAAAAAAACSAAEAAA== | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("John Doe"), "age": Int64(43), "phones": Array([String("+44 1234567"), String("+44 2345678")])}) | nWU8DjJq6h6wosTKvCKttuh0Y9VAIfiXxOtb4fN/Vrg=
 AQAAAAAAAAB6AAEAAQAAAAAAAAC9AAEAAA== | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Bill"), "age": Int64(44), "phones": Array([String("+44 1234567"), String("+44 2345678")])})     | ZwKF0HdZETrq0M6GjmVHN5bFAYzUO0uv9/5RyJBnvnw=
 AQAAAAAAAAB6AAEAAQAAAAAAAADPAAEAAA== | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Bill"), "age": Int64(46), "phones": Array([String("+44 1234567"), String("+44 2345678")])})     | jRk5P/TdjXJX1D2YHfW/5Yfm8qybuWlCrlCQTL4Uz6I=

db3>-$ update-doc --addr 0xef32c065a274503a1f3dff17abaf574ea93b87cf --collection-name books --ids AQAAAAAAAAB6AAEAAQAAAAAAAACSAAEAAA== --documents '{"name": "John","age": 100,"phones": ["+1234567","+2345678"]}' --masks 'name, age, phones'
 mutation id
----------------------------------------------
 T2PXJi7F1205j2jiATNOavu3I80hfIsQL/zkeTgL+aw=
db3>-$ show-doc --addr 0xef32c065a274503a1f3dff17abaf574ea93b87cf --collection-name books
 id_base64                            | owner                                      | document                                                                                                              | mutation_id
--------------------------------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------
 AQAAAAAAAAB6AAEAAQAAAAAAAACSAAEAAA== | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("John"), "age": Int64(100), "phones": Array([String("+1234567"), String("+2345678")])})      | T2PXJi7F1205j2jiATNOavu3I80hfIsQL/zkeTgL+aw=
 AQAAAAAAAAB6AAEAAQAAAAAAAAC9AAEAAA== | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Bill"), "age": Int64(44), "phones": Array([String("+44 1234567"), String("+44 2345678")])}) | ZwKF0HdZETrq0M6GjmVHN5bFAYzUO0uv9/5RyJBnvnw=
 AQAAAAAAAAB6AAEAAQAAAAAAAADPAAEAAA== | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Bill"), "age": Int64(46), "phones": Array([String("+44 1234567"), String("+44 2345678")])}) | jRk5P/TdjXJX1D2YHfW/5Yfm8qybuWlCrlCQTL4Uz6I=
db3>-$

@imotai
Copy link
Contributor

imotai commented Jun 6, 2023

the ut is broken!

@imotai imotai closed this Jun 24, 2023
@imotai imotai deleted the feat/cmd_console_use_indexer_to_query branch July 24, 2023 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Standalone-indexer: console/cmd client take use of indexer-client to query document instead of node-client
2 participants