You are about to give a workshop where you must show how to use a technology and you also need a database for demo purposes, everything is ready, your demo is working and the attendees just need to checkout the initial code.
What could go wrong?
Enter demodb
.
demodb
is a lightweight, native dependencies free, in memory database (you can also save data to disk), built with fastify
and lokijs
.
It exposes a nice HTTP API that you can easily consume from the browser or the server, it does not require authentication and can be run everywhere.
npm i demodb -g
demodb start test
npm i demodb
const Demodb = require('demodb')
const demodb = new Demodb('http://localhost:8081')
const col = demodb.collection('users')
await col.insert({ winter: 'is coming', tag: 'got' })
const result = await col.findOne({ tag: 'got' })
demodb help
The entire API is expose via HTTP, the canonical url is: /db/:collection/:command
. The collection part of the url is the collection name that you are using (like mongo!), the last part is the command you want to run.
The currently supported lokijs
APIs are:
{
method: 'POST',
url: '/db/:collection/find',
body: { your query }
}
{
method: 'POST',
url: '/db/:collection/findOne',
body: { your query }
}
{
method: 'POST',
url: '/db/:collection/insert',
body: { your query }
}
{
method: 'POST',
url: '/db/:collection/update',
body: { your query }
}
{
method: 'POST',
url: '/db/:collection/remove',
body: { your query }
}
If you feel you can help in any way, be it with examples, extra testing, or new features please open a pull request or open an issue.
Copyright © 2018 Tomas Della Vedova