@repositories/inmem
v0.0.0
Published
Generic IRepository implementation using an In-Memory DB
Downloads
6
Maintainers
Readme
InMem-Repository
Installation
$ npm install --save @repositories/inmem
Usage
'use strict'
const mongoose = require('mongoose');
const InMemRepository = require('@repositories/inmem');
class CatRepository extends InMemRepository {
constructor(){
super();
this.find = this.find.bind(this);
}
// custom implementations
find(query, cb) {
this.findAll((err, all) => {
if(err) return cb(err);
cb(null, _.filter(all, query))
});
}
}
// or if you dont need custom functionality
const repo = new InMemRepository();
repo.add({ name: 'Tom' }, (err, doc) => {
console.log(doc);
});
Getting Started
License
MIT © Ben Lugavere