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

Commit d321d02

Browse files
Hayden Youngphillmac
authored andcommitted
Get all key/value pairs for a keyvalue store. (#6)
* Support key/value pairs for keyvalue store. * Additional docs for POSTing key/value pairs. * Display all keys and values from a keyvalue store.
1 parent 907e4d1 commit d321d02

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ curl -X GET http://localhost:3000/db/feed/iterator -d 'limit=-1'
239239
See [OrbitDB's Iterator API](https://github.com/orbitdb/orbit-db/blob/master/API.md#iteratoroptions-1)
240240
for more information.
241241

242+
### GET /db/:dbname/all
243+
244+
Gets all items from a keyvalue database :dbname.
245+
246+
Returns all items from a keyvalue store as a JSON object.
247+
248+
Can only be used on keyvalue.
249+
250+
```shell
251+
curl -X GET http://localhost:3000/db/all
252+
```
253+
254+
```json
255+
{"Key1":{"name":"Value1"},"Key2":{"name":"Value2"},"projects":"{["orbitdb","ipfs"]}}
256+
```
257+
242258
### POST|PUT /db/:dbname/add
243259

244260
Adds a new entry to the eventlog or feed database :dbname.
@@ -273,7 +289,7 @@ For the keyvalue store, a JSON object containing the variables `key` and
273289
`value` must be passed in the POST data:
274290

275291
```shell
276-
curl -X POST http://localhost:3001/db/keyvalue/put -H "Content-Type: application/json" -d '{"key":"Key","value":{ "name": "Value" }}'
292+
curl -X POST http://localhost:3000/db/keyvalue/put -H "Content-Type: application/json" -d '{"key":"Key","value":{ "name": "Value" }}'
277293
```
278294

279295
### POST|PUT /db/:dbname/inc

src/lib/orbitdb-api.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ class OrbitdbAPI extends Express {
160160
return res.json(contents)
161161
}));
162162

163+
this.get('/db/:dbname/all', asyncMiddleware( async (req, res, next) => {
164+
let db
165+
db = await dbm.get(req.params.dbname)
166+
return res.json(db.all())
167+
}));
168+
163169
this.get('/db/:dbname/value', asyncMiddleware( async (req, res, next) => {
164170
let db, val
165171
db = await dbm.get(req.params.dbname)

0 commit comments

Comments
 (0)