This has been moved to a monorepo, https://github.com/blugavere/node-repositories
$ npm install --save mongodb-repository
'use strict'
const MongoRepository = require('mongodb-repository');
class CatRepository extends MongoRepository {
constructor(db, modelName) {
super(db, modelName);
}
}
// or if you dont need custom functionality
const repo = new MongoRepository(db, modelName);
'use strict';
const MongoClient = require('mongodb').MongoClient;
// configure a collection name
const collection = 'cats';
const MongoRepository = require('mongodb-repository');
let repo;
// connect to mongodb
MongoClient.connect('mongodb://localhost', (err, db) => {
// construct a repo
repo = new MongoRepository(db, collection);
repo.add({name:'Fido'}, (err, data) => {
console.log(data);
repo.disconnect();
});
}
MIT © Ben Lugavere