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
FAQ: My data isn't appearing! An explanation of db.load() vs db.events.on("replicated", callback) #579
Comments
Leaving it here but flagging as potential to transfer to the Field Manual. Maybe we can replace this pinned issue with just a link to the Field Manual and a quick blurb. |
it's not clear what "creating a database" means here. Does this reset some pointer somewhere? What if i "create" a database that already exists locally? What if i create a database that already exists on another node and then sync? |
https://github.com/orbitdb/orbit-db/blob/main/API.md#orbitdbcreatename-type-options
this is will error without the overwrite option present. use orbitdb.open to open existing databases.
If the database addresses are the same then the database is the same. |
The one created in the UI: The one created in the app code: |
Thanks @aphelionz for the comprehensive guide. Unfortunately, I feel the replication method is still not functioning correctly. Here is my workflow:
My assumption is (and please tell me if it is wrong) that records added at step 2 should be available and loaded into the remote db during step 3? Also, the fact that step 4 completes successfully would suggest both dbs can see each other and replication IS working. I think the problem myself and @mar1n3r0 are experiencing are similar, the only difference I can see is that the orbitdb hash I use is the same on both local and remote because I use Metamask to handle the identity. |
Closing. db.load is no longer available in v1.0 of OrbitDB. This discussion probably does not apply to the latest release. |
There's been a number of questions lately about data not appearing in the store when you expect, so I thought it would be a good time to take a second to explain the process of opening a database and getting data out of it. The database can be either local or remote.
Important Note: While content discovery can happen via the IPFS distributed hash table, due to the limitations of browser-based IPFS nodes, it's still best if the necessary peers are directly connected via a call to
ipfs.swarm.connect
The basic flow of data can be summarized as follows:
orbitdb.open
with default options (or its various shorthand methodsorbitdb.keyvalue
,orbitdb.docs
etc) will create a local database and database manifest in the IPFS instance that OrbitDB is interacting with. In traditional database parlance, you can view this as creating an empty schema.db.load
for both local and remote databases which loads data from the local IPFS into memory for use. Basically it's saying, "give me the data this node knows about"listenerFunction
and register it as an event listener ondb.events.on('replicated', function listenerFunction() {})
. This will be fired when data is loaded from a remote source, and again every time those remote data change.In code, this might look something like:
Feel free to respond to this issue with further questions! We want to make sure we're explaining this properly.
The text was updated successfully, but these errors were encountered: