Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/delvedor/demodb
An HTTP based database for demo purposes, workshop and so on.
https://github.com/delvedor/demodb
database utility workshop
Last synced: 1 day ago
JSON representation
An HTTP based database for demo purposes, workshop and so on.
- Host: GitHub
- URL: https://github.com/delvedor/demodb
- Owner: delvedor
- License: mit
- Created: 2018-07-14T06:50:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-15T10:46:37.000Z (over 6 years ago)
- Last Synced: 2024-12-31T10:14:42.369Z (8 days ago)
- Topics: database, utility, workshop
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# demodb
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/delvedor/demodb.svg?branch=master)](https://travis-ci.org/delvedor/demodb)
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`](https://github.com/fastify/fastify) and [`lokijs`](https://github.com/techfort/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
```
```js
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`](https://github.com/techfort/LokiJS) APIs are:#### `find`
```js
{
method: 'POST',
url: '/db/:collection/find',
body: { your query }
}
```
#### `findOne`
```js
{
method: 'POST',
url: '/db/:collection/findOne',
body: { your query }
}
```
#### `insert`
```js
{
method: 'POST',
url: '/db/:collection/insert',
body: { your query }
}
```
#### `update`
```js
{
method: 'POST',
url: '/db/:collection/update',
body: { your query }
}
```
#### `remove`
```js
{
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](https://github.com/delvedor/demodb/blob/master/LICENSE)**Copyright © 2018 Tomas Della Vedova