Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mrvautin/octo-db

A flatfile JSON db for prototyping
https://github.com/mrvautin/octo-db

database db javascript nodejs

Last synced: 16 days ago
JSON representation

A flatfile JSON db for prototyping

Awesome Lists containing this project

README

        

# octo-db

`octo-db` is a simple flat file JSON DB to be used for prototyping and testing. Super easy to setup and use.

### Setup

``` javascript
const db = require('octo-db');
db.setup({
file: 'path/to/my/file-db.json'
});
```

### Insert

``` javascript
const db = require('octo-db');
const result = await db.insert({
email: '[email protected]',
firstName: 'Peter',
lastName: 'Smith',
address1: '1 Adelaide Street',
address2: '',
country: 'Australia',
state: 'VIC',
postcode: '3000',
phone: '0412345678'
});
console.log(result);
```

### Query

``` javascript
const db = require('octo-db');
const query = await db.query({
email: '[email protected]'
});
console.log(query);
```

### Remove

``` javascript
const db = require('octo-db');
const remove = await db.remove({
email: '[email protected]'
});
console.log(remove);
```

### Flush DB

This removes all records from the DB

``` javascript
const db = require('octo-db');
await db.flushDb();
```

### Update

Update takes two args. First the matching object then the keys/value to update. Eg: This updates all records which have an email of `[email protected]` to `[email protected]` and returns the result.

``` javascript
const db = require('octo-db');
const update = await db.update({
email: '[email protected]'
},{
email: '[email protected]'
});

console.log(update);
```