0.2.0 • Published 6 years ago

demodb v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

demodb

js-standard-style Build Status

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?

Everything!

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.

Install

npm i demodb -g

Usage

demodb start test

Client usage

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' })

Need help?

demodb help

API

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:

find

{
  method: 'POST',
  url: '/db/:collection/find',
  body: { your query }
}

findOne

{
  method: 'POST',
  url: '/db/:collection/findOne',
  body: { your query }
}

insert

{
  method: 'POST',
  url: '/db/:collection/insert',
  body: { your query }
}

update

{
  method: 'POST',
  url: '/db/:collection/update',
  body: { your query }
}

remove

{
  method: 'POST',
  url: '/db/:collection/remove',
  body: { your query }
}

Contributing

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.

License

MIT

Copyright © 2018 Tomas Della Vedova