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/delete doc #314

Merged
merged 4 commits into from
Feb 13, 2023
Merged

Feat/delete doc #314

merged 4 commits into from
Feb 13, 2023

Conversation

jingchen2222
Copy link
Collaborator

@jingchen2222 jingchen2222 commented Feb 12, 2023

Changes

  • add delete_document(...) in db_store
  • add cmd 'delete-doc --ids 'document ids'

Demo

██████╗ ██████╗ ██████╗
██╔══██╗██╔══██╗╚════██╗
██║  ██║██████╔╝ █████╔╝
██║  ██║██╔══██╗ ╚═══██╗
██████╔╝██████╔╝██████╔╝
╚═════╝ ╚═════╝ ╚═════╝
@db3.network🚀🚀🚀
db3>-$ init
 address                                    | scheme
--------------------------------------------+-----------
 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | secp256k1
db3>-$ new-db
 database address                           | transaction id
--------------------------------------------+----------------------------------------------
 0x29c1aec17c10ae8cc2480d011dfb971d3698e30a | jY69h22RJewlHod0ifvIMycjC7ga3mI0SUQvNuO1bbM=
db3>-$ new-collection --addr 0x29c1aec17c10ae8cc2480d011dfb971d3698e30a --name books --index '{"id":1,"name":"idx1","fields":[{"field_path":"name","value_mode":{"Order":1}}]}'
send add collection done!
 tx_id
----------------------------------------------
 Rh9VBUMm3GDbj16Z3xkO9ggfG5z/pUxdpA0YBfDZE2k=
db3>-$ new-doc --addr 0x29c1aec17c10ae8cc2480d011dfb971d3698e30a --collection-name books --documents '{"name": "John Doe","age": 43,"phones": ["+44 1234567","+44 2345678"]}'
send add document done
 transaction id
----------------------------------------------
 qonJ5fXKPesadJ+lHDPJGMVRrkgtMtqHEiwp12DsEpk=
db3>-$ new-doc --addr 0x29c1aec17c10ae8cc2480d011dfb971d3698e30a --collection-name books --documents '{"name": "Mike","age": 44,"phones": ["+44 1234567","+44 2345678"]}'
send add document done
 transaction id
----------------------------------------------
 SrecRAcBT5VYNHvh8N1/hUIvt7TXONZWMz1XYgvt45s=
db3>-$ new-doc --addr 0x29c1aec17c10ae8cc2480d011dfb971d3698e30a --collection-name books --documents '{"name": "Bob","age": 45,"phones": ["+44 1234567","+44 2345678"]}'
send add document done
 transaction id
----------------------------------------------
 8nCT3KNb7eA+crwuO0sBOXRKoljtspanZa8i9e17bMY=
db3>-$ show-doc --addr 0x29c1aec17c10ae8cc2480d011dfb971d3698e30a --collection-name books
 id_base64                                    | owner                                      | document                                                                                                                  | tx_id
----------------------------------------------+--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------
 AQAAAAAAAAClAAAAAQAAAAEAAAAAAAAAvgAAAAEAAAAA | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("John Doe"), "age": Int64(43), "phones": Array([String("+44 1234567"), String("+44 2345678")])}) | qonJ5fXKPesadJ+lHDPJGMVRrkgtMtqHEiwp12DsEpk=
 AQAAAAAAAAClAAAAAQAAAAEAAAAAAAAAxgAAAAEAAAAA | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Mike"), "age": Int64(44), "phones": Array([String("+44 1234567"), String("+44 2345678")])})     | SrecRAcBT5VYNHvh8N1/hUIvt7TXONZWMz1XYgvt45s=
 AQAAAAAAAAClAAAAAQAAAAEAAAAAAAAAzQAAAAEAAAAA | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Bob"), "age": Int64(45), "phones": Array([String("+44 1234567"), String("+44 2345678")])})      | 8nCT3KNb7eA+crwuO0sBOXRKoljtspanZa8i9e17bMY=
db3>-$ del-doc --addr 0x29c1aec17c10ae8cc2480d011dfb971d3698e30a --collection-name books --ids AQAAAAAAAAClAAAAAQAAAAEAAAAAAAAAvgAAAAEAAAAA
send delete document done
 transaction id
----------------------------------------------
 O6198vfjGaWK2/wjkgpEhZcbbaSS7mqq+GG9fft49f4=
db3>-$ show-doc --addr 0x29c1aec17c10ae8cc2480d011dfb971d3698e30a --collection-name books
 id_base64                                    | owner                                      | document                                                                                                              | tx_id
----------------------------------------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------
 AQAAAAAAAAClAAAAAQAAAAEAAAAAAAAAxgAAAAEAAAAA | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Mike"), "age": Int64(44), "phones": Array([String("+44 1234567"), String("+44 2345678")])}) | SrecRAcBT5VYNHvh8N1/hUIvt7TXONZWMz1XYgvt45s=
 AQAAAAAAAAClAAAAAQAAAAEAAAAAAAAAzQAAAAEAAAAA | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Bob"), "age": Int64(45), "phones": Array([String("+44 1234567"), String("+44 2345678")])})  | 8nCT3KNb7eA+crwuO0sBOXRKoljtspanZa8i9e17bMY=

@codecov
Copy link

codecov bot commented Feb 12, 2023

Codecov Report

Merging #314 (85684e0) into main (ee1f350) will increase coverage by 1.04%.
The diff coverage is 92.97%.

@@            Coverage Diff             @@
##             main     #314      +/-   ##
==========================================
+ Coverage   61.82%   62.87%   +1.04%     
==========================================
  Files          57       57              
  Lines        6151     6357     +206     
==========================================
+ Hits         3803     3997     +194     
- Misses       2348     2360      +12     
Flag Coverage Δ
rust 62.87% <92.97%> (+1.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/error/src/lib.rs 100.00% <ø> (ø)
src/cmd/src/command.rs 74.59% <91.48%> (+3.27%) ⬆️
src/storage/src/db_store.rs 89.58% <92.26%> (+0.94%) ⬆️
src/crypto/src/id.rs 94.63% <100.00%> (ø)
src/node/src/command.rs 39.02% <100.00%> (+4.28%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jingchen2222 jingchen2222 linked an issue Feb 13, 2023 that may be closed by this pull request
Copy link
Contributor

@imotai imotai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@imotai imotai merged commit e6a9bfa into main Feb 13, 2023
@imotai imotai deleted the feat/delete_doc branch February 14, 2023 15:10
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.

2 participants