Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Commit 35a3917

Browse files
committed
update docs
1 parent e9c934d commit 35a3917

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,28 @@ const IPFS = require('ipfs')
3434
const OrbitDB = require('orbit-db')
3535

3636
const ipfs = new IPFS()
37-
const orbitdb = new OrbitDB(ipfs)
37+
const orbitdb = await OrbitDB.createInstance(ipfs)
3838
```
3939

4040
Get 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')
4444
log.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

5252
Later, 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')
5656
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))
5959
// "hello world"
6060
})
6161
```

0 commit comments

Comments
 (0)