diff --git a/README.md b/README.md index 3328847..bcfb9e7 100644 --- a/README.md +++ b/README.md @@ -269,6 +269,13 @@ curl -X POST http://localhost:3000/db/docstore/put -H "Content-Type: application zdpuAkkFaimxyRE2bsiLRSiybkku3oDi4vFHqPZh29BABZtZU ``` +For the keyvalue store, a JSON object containing the variables `key` and +`value` must be passed in the POST data: + +```shell +curl -X POST http://localhost:3001/db/keyvalue/put -H "Content-Type: application/json" -d '{"key":"Key","value":{ "name": "Value" }}' +``` + ### POST|PUT /db/:dbname/inc Increments the counter database :dbname by 1. diff --git a/src/lib/orbitdb-api.js b/src/lib/orbitdb-api.js index d448ae9..437710b 100644 --- a/src/lib/orbitdb-api.js +++ b/src/lib/orbitdb-api.js @@ -66,7 +66,14 @@ class OrbitdbAPI extends Express { var db_put = asyncMiddleware( async (req, res, next) => { let db, hash db = await dbm.get(req.params.dbname) - hash = await db.put(req.body) + + if (db.type == 'keyvalue') { + let params = req.body; + hash = await db.put(params.key, params.value) + } else { + hash = await db.put(req.body) + } + return res.json(hash) });