Skip to content

Instantly share code, notes, and snippets.

@ptoner
Created August 10, 2019 18:35
Show Gist options
  • Save ptoner/1bfb38c230bd6a0931ad3674e3a51ca1 to your computer and use it in GitHub Desktop.
Save ptoner/1bfb38c230bd6a0931ad3674e3a51ca1 to your computer and use it in GitHub Desktop.
//Add 100 records to the store
for (var i=0; i < 100; i++) {
await store.add({content: (i + 10).toString() })
}
//Close the store
await store.close()
//Ok now reopen it
store = await orbitdb.open("store address")
//Index is now empty. Which makes sense.
//So I want to load the first 5 records
await store.load(5)
//Ok good there's now 5 records in the index
let it = await store.iterator().collect()..
//"it" has those 5.
//Ok so now how do I get to the other ones?
//I tried calling store.iterator() and passing in a hash of a record that's further down than these 5.
//It doesn't return anything. Presumably because those records weren't loaded.
//So I try loading more
await store.load(50)
//The index still has the original 5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment