octo-db
v1.0.0
Published
A flatfile JSON db for prototyping
Downloads
8
Maintainers
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
const db = require('octo-db');
db.setup({
file: 'path/to/my/file-db.json'
});Insert
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
const db = require('octo-db');
const query = await db.query({
email: '[email protected]'
});
console.log(query);Remove
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
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.
const db = require('octo-db');
const update = await db.update({
email: '[email protected]'
},{
email: '[email protected]'
});
console.log(update);