1.0.1 • Published 5 years ago

impulse-mongo v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

impulse-mongo

MongoDB plugin for nef

Install

npm install impulse-mongo --save

Usage

const nef = require('nef');
const nefMongo = require('impulse-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.

LICENSE

MIT