# mongorepository

> Generic implementation of the repository pattern for nodejs/mongodb

Latest version **1.1.1** (published 2013-09-26) · 0 weekly downloads

## Install

```sh
npm install mongorepository
pnpm add mongorepository
yarn add mongorepository
bun add mongorepository
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2013-09-26 |
| First published | 2012-02-25 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | IainJMitchell |
| Maintainers | iainjmitchell, benoj |
| Keywords | mongodb |

## Links

- npm: https://www.npmjs.com/package/mongorepository
- Repository: http://github.com/iainjmitchell/mongorepository
- Issues: https://github.com/iainjmitchell/mongorepository/issues
- npm.io page: https://npm.io/package/mongorepository

## Dependencies (1)

- [mongojs](https://npm.io/package/mongojs.md) >=0.3.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2013-09-26
- 1.1.0 — 2013-09-25
- 1.0.2 — 2013-09-04
- 1.0.1 — 2013-07-15
- 1.0.0 — 2012-02-25

## README

# mongorepository
A [node.js](http://nodejs.org/) module that contains a generic implementation of the [Repository Pattern](http://martinfowler.com/eaaCatalog/repository.html) for [mongoDB](http://www.mongodb.org/).

### Installation
The easiest way to install is through the Node Package Manager ([NPM](http://npmjs.org/)):

``` js
npm install mongorepository
```

### Usage
``` js 
//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);

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

---
_Source: https://npm.io/package/mongorepository · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
