# mongoose-lean

> Default Mongoose to use lean queries. Fatten them back up with syntactic sugar.

Latest version **1.0.0** (published 2014-12-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongoose-lean
pnpm add mongoose-lean
yarn add mongoose-lean
bun add mongoose-lean
```

## 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.0.0 |
| Published | 2014-12-31 |
| First published | 2014-12-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Good Eggs |
| Maintainers | bobzoller |
| Keywords | mongoose mongo lean fat |

## Links

- npm: https://www.npmjs.com/package/mongoose-lean
- Repository: https://github.com/goodeggs/mongoose-lean
- Issues: https://github.com/goodeggs/mongoose-lean/issues
- npm.io page: https://npm.io/package/mongoose-lean

## 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.0.0 (latest) — 2014-12-31

## README

# mongoose-lean

Default [Mongoose](http://mongoosejs.com/) to use lean queries.  Fatten them back up with syntactic sugar.

[![NPM version](http://img.shields.io/npm/v/mongoose-lean.svg?style=flat-square)](https://www.npmjs.org/package/mongoose-lean)
[![Build Status](http://img.shields.io/travis/goodeggs/mongoose-lean.svg?style=flat-square)](https://travis-ci.org/goodeggs/mongoose-lean)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/goodeggs/mongoose-lean/blob/master/LICENSE.md)

## Usage

First a word of warning: the current implementation patches mongoose directly, which means if any of your code *or dependencies* expects the default un-patched mongoose, you'll be in trouble.  I'm interested in changing the implementation to opt-in to this behavior on a per-model basis, which should avoid this.

```
npm install mongoose-lean
```

```javascript
var mongoose = require('mongoose');
var patchMongoose = require('mongoose-lean');
patchMongoose(mongoose);

var User = mongoose.model('User', new mongoose.Schema({name: String}));

function weighIn(bob) {
  console.log('bob is ', bob instanceof User ? 'fat' : 'lean');
}

User.create({name: 'Bob'}, function(err, bob) {
  weighIn(bob); // => bob is fat
  User.findById(bob._id, function(err, bob) {
    weighIn(bob); // => bob is lean
    User.findById(bob._id).fat().exec(function(err, bob) {
      weighIn(bob); // => bob is fat
    });
  });
});
```

## Contributing

Please follow our [Code of Conduct](https://github.com/goodeggs/mongoose-lean/blob/master/CODE_OF_CONDUCT.md)
when contributing to this project.

```
$ git clone https://github.com/goodeggs/mongoose-lean && cd mongoose-lean
$ npm install
$ npm test
```

_Module scaffold generated by [generator-goodeggs-npm](https://github.com/goodeggs/generator-goodeggs-npm)._

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