7
7
8
8
Database for storing indexed documents. Stores documents by ` _id ` field by default but you can also specify a custom field to index by.
9
9
10
- * This is a core data store in [ orbit-db] ( https://github.com/haadcode /orbit-db ) *
10
+ * This is a core data store in [ orbit-db] ( https://github.com/orbitdb /orbit-db ) *
11
11
12
12
## Table of Contents
13
13
@@ -32,8 +32,8 @@ const IPFS = require('ipfs')
32
32
const OrbitDB = require (' orbit-db' )
33
33
34
34
const ipfs = new IPFS ()
35
- const orbitdb = new OrbitDB (ipfs)
36
- const docstore = orbitdb .docstore (' db name' )
35
+ const orbitdb = await OrbitDB . createInstance (ipfs)
36
+ const docstore = await orbitdb .docstore (' db name' )
37
37
38
38
docstore .put ({ _id: ' hello world' , doc: ' all the things' })
39
39
.then (() => docstore .put ({ _id: ' sup world' , doc: ' other things' }))
@@ -46,7 +46,7 @@ docstore.put({ _id: 'hello world', doc: 'all the things' })
46
46
You can specify the field to index by in the options:
47
47
48
48
``` javascript
49
- const docstore = orbitdb .docstore (' db name' , { indexBy: ' doc' })
49
+ const docstore = await orbitdb .docstore (' db name' , { indexBy: ' doc' })
50
50
51
51
docstore .put ({ _id: ' hello world' , doc: ' some things' })
52
52
.then (() => docstore .put ({ _id: ' hello universe' , doc: ' all the things' }))
@@ -59,7 +59,7 @@ docstore.put({ _id: 'hello world', doc: 'some things' })
59
59
You can also use a mapper to query the documents
60
60
61
61
``` javascript
62
- const docstore = orbitdb .docstore (' db name' )
62
+ const docstore = await orbitdb .docstore (' db name' )
63
63
64
64
docstore .put ({ _id: ' hello world' , doc: ' some things' , views: 10 })
65
65
.then (() => docstore .put ({ _id: ' hello universe' , doc: ' all the things' , views: 100 }))
@@ -71,21 +71,21 @@ docstore.put({ _id: 'hello world', doc: 'some things', views: 10 })
71
71
72
72
## API
73
73
74
- * See [ orbit-db API documentation] ( https://github.com/haadcode /orbit-db/blob/master/API.md ) for full details*
74
+ * See [ orbit-db API documentation] ( https://github.com/orbitdb /orbit-db/blob/master/API.md ) for full details*
75
75
76
76
### docstore(name, options)
77
77
78
78
Package:
79
- [ orbit-db-docstore] ( https://github.com/shamb0t /orbit-db-docstore )
79
+ [ orbit-db-docstore] ( https://github.com/orbitdb /orbit-db-docstore )
80
80
81
81
``` javascript
82
- const db = orbitdb .docstore (' orbit.users.shamb0t.profile' )
82
+ const db = await orbitdb .docstore (' orbit.users.shamb0t.profile' )
83
83
```
84
84
85
85
By default, documents are indexed by field '_ id'. You can also specify the field to index by:
86
86
87
87
``` javascript
88
- const db = orbitdb .docstore (' orbit.users.shamb0t.profile' , { indexBy: ' name' })
88
+ const db = await orbitdb .docstore (' orbit.users.shamb0t.profile' , { indexBy: ' name' })
89
89
```
90
90
91
91
- ** put(doc)**
0 commit comments