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')
34
34
const OrbitDB = require (' orbit-db' )
35
35
36
36
const ipfs = new IPFS ()
37
- const orbitdb = new OrbitDB (ipfs)
37
+ const orbitdb = await OrbitDB . createInstance (ipfs)
38
38
```
39
39
40
40
Get a log database and add an entry to it:
41
41
42
42
``` javascript
43
- const log = orbitdb .eventlog (' haad.posts' )
43
+ const log = await orbitdb .eventlog (' haad.posts' )
44
44
log .add ({ name: ' hello world' })
45
45
.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 ))
48
48
// "hello world"
49
49
})
50
50
```
51
51
52
52
Later, when the database contains data, load the history and query when ready:
53
53
54
54
``` javascript
55
- const log = orbitdb .eventlog (' haad.posts' )
55
+ const log = await orbitdb .eventlog (' haad.posts' )
56
56
log .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 ))
59
59
// "hello world"
60
60
})
61
61
```
You can’t perform that action at this time.
0 commit comments