nef-mongo
v1.0.1
Published
MongoDB plugin for nef
Downloads
102
Maintainers
Readme
nef-mongo
MongoDB plugin for nef
Install
npm install nef-mongo --save
Usage
const nef = require('nef');
const nefMongo = require('nef-mongo');
const db = nef(nefMongo('mongodb://localhost:27017/myproject'));
db.money.set('phil', 10);
db.money.set('some_user', db.money.get('phil') + 10);
db.seen.set('some_user', Date.now());
db.posts.set('posts', [
{ title: 'OriginDB is awesome!', body: '...', likes: 10 },
{ title: 'flexbility ', body: '...', likes: 3 },
{ title: 'something someting something', body: '...', likes: 8 }
]);
In MongoDB:
{
"_id" : ObjectId("567e4741b09bffce48aa98b1"),
"name" : "money",
"data" : "{\"phil\":10,\"some_user\":20}"
}
{
"_id" : ObjectId("567e4741b09bffce48aa98b2"),
"name" : "seen",
"data" : "{\"some_user\":1451116353687}"
}
{
"_id" : ObjectId("567e4741b09bffce48aa98b3"),
"name" : "posts",
"data" : "{\"posts\":[{\"title\":\"OriginDB is awesome!\",\"body\":\"...\",\"likes\":10},{\"title\":\"flexbility \",\"body\":\"...\",\"likes\":3},{\"title\":\"something someting something\",\"body\":\"...\",\"likes\":8}]}"
}
Docs
nefMongo(url)
Loads in data and save function using nef collection of MongoDB.