Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/mrvautin/octo-db
- Owner: mrvautin
- Created: 2019-12-04T08:53:35.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T02:17:57.000Z (almost 2 years ago)
- Last Synced: 2024-11-20T07:23:52.523Z (about 1 month ago)
- Topics: database, db, javascript, nodejs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/octo-db
- Size: 622 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
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);
```