Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-lean

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-lean

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

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

mongoose-lean

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

NPM version Build Status MIT License

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
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 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.

Keywords

FAQs

Package last updated on 31 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc