eos

eosdb

Serverless and flexible JSON database.

Showing:

Popularity

Downloads/wk

1

Maintenance

No Maintenance Data Available

Package

Dependencies

3

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

eosdb Build Status Dependency Status devDependency Status

Serverless and flexible JSON database.

Each key in the db object corresponds to a JSON file.

Install

$ npm install eosdb --save

Usage

var db = require('eosdb')('directory_name');
db('money').phil = 10;
db('seen').some_user = Date.now();
db('posts').posts = [
  { title: 'eosdb is awesome!', body: '...', likes: 10 },
  { title: 'flexbility ', body: '...', likes: 3 },
  { title: 'something someting something', body: '...', likes: 8 }
];
db.save();

In directory_name folder:

// money.json
{
  "phil": 10
}

// seen.json
{
  "some_user": 1439674925906
}

// posts.json
{
  "posts": [
    { "title": "eosdb is awesome!", "body": "...", "likes": 10 },
    { "title": "flexbility ", "body": "...", "likes": 3 },
    { "title": "something someting something", "body": "...", "likes": 8 }
  ]
}

Size

for (var i = 0; i < 10; i++) {
  db('num')[i] = i; 
}
console.log(db.size('num')); // outputs 10

Helper get methods

Helper get methods are just get methods that contains a default value if it is not the specify type.

Why? This is so you don't have to type this everywhere in your code:

var some_amount = 10;
var val = db('money')['some_user'];
db('money')['some_user'] = (val || 0) + some_amount;

It is much easier and faster to do this:

var some_amount = 10;
db('money')['some_user'] = db.nget('money', 'some_user') + some_amount;

aget(file, key)

Get an array value, defaults to [].

Parameters:

file: String key: String

Returns: Array

nget(file, key)

Get a number value, defaults to 0.

Parameters:

file: String key: String

Returns: Number

sget(file, key)

Get a string value, defaults to "".

Parameters:

file: String key: String

Returns: String

License

MIT © Phil

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial