This repository was archived by the owner on Sep 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -34,28 +34,28 @@ const IPFS = require('ipfs')
3434const OrbitDB = require (' orbit-db' )
3535
3636const ipfs = new IPFS ()
37- const orbitdb = new OrbitDB (ipfs)
37+ const orbitdb = await OrbitDB . createInstance (ipfs)
3838```
3939
4040Get a log database and add an entry to it:
4141
4242``` javascript
43- const log = orbitdb .eventlog (' haad.posts' )
43+ const log = await orbitdb .eventlog (' haad.posts' )
4444log .add ({ name: ' hello world' })
4545 .then (() => {
46- const items = log .iterator ().collect ()
47- items .forEach (( e ) => console .log (e .name ))
46+ const items = log .iterator ().collect (). map ( e => e . payload . value )
47+ items .forEach (e => console .log (e .name ))
4848 // "hello world"
4949 })
5050```
5151
5252Later, when the database contains data, load the history and query when ready:
5353
5454``` javascript
55- const log = orbitdb .eventlog (' haad.posts' )
55+ const log = await orbitdb .eventlog (' haad.posts' )
5656log .events .on (' ready' , () => {
57- const items = log .iterator ().collect ()
58- items .forEach (( e ) => console .log (e .name ))
57+ const items = log .iterator ().collect (). map ( e => e . payload . value )
58+ items .forEach (e => console .log (e .name ))
5959 // "hello world"
6060})
6161```
You can’t perform that action at this time.
0 commit comments