Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ curl -X POST http://localhost:3000/db/counter/inc/100
zdpuAmHw9Tcc4pyVjcVX3rJNJ7SGffmu4EwjodzmaPBVGGzbd
```

### DELETE /db/:dbname

Deletes the local database :dbname. This does not delete any data from peers.

```shell
curl -X DELETE http://localhost:3000/db/docstore
```

### DELETE /db/:dbname/:item

Deletes the item specified by :item from the database :dbname.
Expand Down
5 changes: 4 additions & 1 deletion src/lib/db-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class DBManager {
}
};

this.db_list_remove = (dbname) => {
delete _dbs[dbname];
}

this.db_list = () => {
let db_info_list = {};
for (var dbn in _dbs) {
Expand Down Expand Up @@ -50,4 +54,3 @@ class DBManager {
}

module.exports = DBManager;

9 changes: 9 additions & 0 deletions src/lib/orbitdb-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ class OrbitdbAPI extends Express {
}
});

this.delete('/db/:dbname', asyncMiddleware( async (req, res, next) => {
let db
db = await dbm.get(req.params.dbname)

await db.drop()
dbm.db_list_remove(req.params.dbname)
return res.json('')
}))

this.delete('/db/:dbname/:item', asyncMiddleware( async (req, res, next) => {
let db, hash
db = await dbm.get(req.params.dbname)
Expand Down