Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

nodejs npm package for repository pattern with mongodb database

Notifications You must be signed in to change notification settings

iixlabs/mongorepositiory

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongorepository

A node.js module that contains a generic implementation of the Repository Pattern for mongoDB.

Installation

The easiest way to install is through the Node Package Manager (NPM):

npm install mongorepository

Usage

//reference the repository object
var Repository = require('mongoRepository').Repository;

//create an instance
var catRepository = new Repository('username:password@localhost/dbname', 'cat');

var cat = {
  _id : 101,
  name: 'trevor'
}

//add cat
catRepository.add(cat);

//get cat by id
catRepository.get(101, function(returnedCat){
	console.log(returnedCat);
});

//find cat
query = {name: 'trevor'}
catRepository.find(query, function(results){
  console.log(results);
});

//update cat
cat.age = 4;
catRepository.update(query, cat);

cat.age = 5;
catRepository.update(query, cat, function () {
	console.log("Updated ", cat);
});

//delete cat
catRepository.remove(query,function(){
	console.log("Removed ",cat);
});

catRepository.remove(query);

About

nodejs npm package for repository pattern with mongodb database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 91.5%
  • Ruby 8.5%