Closed MeowDada closed 4 years ago
I think your change will break the expected behaviour. Did you get a different address on reopened stores? You can normally inspect it via store.Address().String()
.
If you provide an orbitdb address instead of a name the store won't be recreated and data will be loaded from peers.
This is also how the reference JS implementation works when no parameter has been specified.
GitHubPeer-to-Peer Databases for the Decentralized Web. Contribute to orbitdb/orbit-db development by creating an account on GitHub.
You keep the default value (options.Create = boolPtr(true)
) when it has not been provided. This change could also be applied to the Log()
method.
Hi, @glouvigny Thanks for your fast response ! It's pretty helpful.
I think this pull request could be closed due to the reason you had pointed out.
It will break the API behaviour because the JS implementation does always set create = true
when using keyvalue (address, options = {})
My original question and description is quite misleading so let me reintroduce what I thought.
What I really want to do is to open an existing kv store but not to create a new one if it does not exist .
And it seems like using KeyValue
API to open a kv store will always create a new one if it does not exist.
Although I haven't try it yet but below codes should work fine as my expectation.
store, _ := db.Open(ctx, addr, &iface.CreateDBOptions{
Create: boolPtr(false),
})
kv := store.(iface.KeyValueStore)
Say we have an instance of iface.OrbitDB as
db
. If we're intended to open an existing key value store, we can use something described as below:But it will always create a new database, even if we set the option
Create
to false. The fix should be removing the code which always setoption.Create = true