rouchdb
v0.0.3
Published
Simple NoSQL DB for fast apps prototyping
Readme
RouchDB
Simple embeddable NoSQL DB for fast apps prototyping.
It's early version and under heavy development. Most of functions is unavailable.
Usage
npm install rouchdbimport async from 'async';
import RouchDB from '../index';
let db = new RouchDB({path: __dirname});
db.createCollection('users', (err, users) => {
// define view for count users in each country
users.createView('by-countries', {
map: (user, emit) => {
emit(user.country, 1);
},
reduce: (id, values, rereduce) => {
return values.length;
}
});
async.each([
{_id: 1, name: 'Frodo', country: 'Shire'},
{_id: 2, name: 'Sam', country: 'Shire'},
{_id: 3, name: 'Meriadoc', country: 'Shire'},
{_id: 4, name: 'Peregrin', country: 'Shire'},
{_id: 5, name: 'Aragorn', country: 'Gondor'},
{_id: 6, name: 'Sauron', country: 'Mordor'}
], (user, cb) => {
// fill db with demo values
users.put(user, cb);
}, () => {
// call view
users.views['by-countries'].run({reduce: true}).toArray((result) => {
console.log(result); // {Shire: 4, Gondor: 1, Mordor: 1}
});
});
});