{
  "name": "mongoose",
  "description": "Mongoose MongoDB ODM",
  "version": "3.8.4",
  "author": {
    "name": "Guillermo Rauch",
    "email": "guillermo@learnboost.com"
  },
  "keywords": [
    "mongodb",
    "document",
    "model",
    "schema",
    "database",
    "odm",
    "data",
    "datastore",
    "query",
    "nosql",
    "orm",
    "db"
  ],
  "dependencies": {
    "hooks": "0.2.1",
    "mongodb": "1.3.23",
    "ms": "0.1.0",
    "sliced": "0.0.5",
    "muri": "0.3.1",
    "mpromise": "0.4.3",
    "mpath": "0.1.1",
    "regexp-clone": "0.0.1",
    "mquery": "0.4.1"
  },
  "devDependencies": {
    "mocha": "1.12.0",
    "node-static": "0.5.9",
    "dox": "0.3.1",
    "jade": "0.26.3",
    "highlight.js": "7.0.1",
    "markdown": "0.3.1",
    "promises-aplus-tests": ">= 1.0.2",
    "tbd": "0.6.4",
    "benchmark": "1.0.0",
    "open": "0.0.3",
    "async": "0.2.5"
  },
  "directories": {
    "lib": "./lib/mongoose"
  },
  "scripts": {
    "test": "make test"
  },
  "main": "./index.js",
  "engines": {
    "node": ">=0.6.19"
  },
  "bugs": {
    "url": "https://github.com/learnboost/mongoose/issues/new",
    "email": "mongoose-orm@googlegroups.com"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/LearnBoost/mongoose.git"
  },
  "homepage": "http://mongoosejs.com",
  "readme": "# Mongoose\n\nMongoose is a [MongoDB](http://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment.\n\n[![Build Status](https://travis-ci.org/LearnBoost/mongoose.png?branch=3.8.x)](https://travis-ci.org/LearnBoost/mongoose)\n\n## Documentation\n\n[mongoosejs.com](http://mongoosejs.com/)\n\n## Support\n\n  - [Stack Overflow](http://stackoverflow.com/questions/tagged/mongoose)\n  - [bug reports](https://github.com/learnboost/mongoose/issues/)\n  - [help forum](http://groups.google.com/group/mongoose-orm)\n  - [MongoDB support](http://www.mongodb.org/display/DOCS/Technical+Support)\n  - (irc) #mongoosejs on freenode\n\n## Plugins\n\nCheck out the [plugins search site](http://plugins.mongoosejs.com/) to see hundreds of related modules from the community.\n\n## Contributors\n\nView all 100+ [contributors](https://github.com/learnboost/mongoose/graphs/contributors). Stand up and be counted as a [contributor](https://github.com/LearnBoost/mongoose/blob/master/CONTRIBUTING.md) too!\n\n## Live Examples\n<a href=\"https://runnable.com/mongoose\" target=\"_blank\"><img src=\"https://runnable.com/external/styles/assets/runnablebtn.png\" style=\"width:67px;height:25px;\"></a>\n\n## Installation\n\nFirst install [node.js](http://nodejs.org/) and [mongodb](http://www.mongodb.org/downloads). Then:\n\n    $ npm install mongoose\n    \n## Stability\n\nThe current stable branch is [3.8.x](https://github.com/LearnBoost/mongoose/tree/3.8.x). New (unstable) development always occurs on the [master](https://github.com/LearnBoost/mongoose/tree/master) branch.\n\n## Overview\n\n### Connecting to MongoDB\n\nFirst, we need to define a connection. If your app uses only one database, you should use `mongoose.connect`. If you need to create additional connections, use `mongoose.createConnection`.\n\nBoth `connect` and `createConnection` take a `mongodb://` URI, or the parameters `host, database, port, options`.\n\n    var mongoose = require('mongoose');\n\n    mongoose.connect('mongodb://localhost/my_database');\n\nOnce connected, the `open` event is fired on the `Connection` instance. If you're using `mongoose.connect`, the `Connection` is `mongoose.connection`. Otherwise, `mongoose.createConnection` return value is a `Connection`.\n\n**Important!** Mongoose buffers all the commands until it's connected to the database. This means that you don't have to wait until it connects to MongoDB in order to define models, run queries, etc.\n\n### Defining a Model\n\nModels are defined through the `Schema` interface. \n\n    var Schema = mongoose.Schema\n      , ObjectId = Schema.ObjectId;\n\n    var BlogPost = new Schema({\n        author    : ObjectId\n      , title     : String\n      , body      : String\n      , date      : Date\n    });\n\nAside from defining the structure of your documents and the types of data you're storing, a Schema handles the definition of:\n\n* [Validators](http://mongoosejs.com/docs/validation.html) (async and sync)\n* [Defaults](http://mongoosejs.com/docs/api.html#schematype_SchemaType-default)\n* [Getters](http://mongoosejs.com/docs/api.html#schematype_SchemaType-get)\n* [Setters](http://mongoosejs.com/docs/api.html#schematype_SchemaType-set)\n* [Indexes](http://mongoosejs.com/docs/guide.html#indexes)\n* [Middleware](http://mongoosejs.com/docs/middleware.html)\n* [Methods](http://mongoosejs.com/docs/guide.html#methods) definition\n* [Statics](http://mongoosejs.com/docs/guide.html#statics) definition\n* [Plugins](http://mongoosejs.com/docs/plugins.html)\n* [pseudo-JOINs](http://mongoosejs.com/docs/populate.html)\n\nThe following example shows some of these features:\n\n    var Comment = new Schema({\n        name  :  { type: String, default: 'hahaha' }\n      , age   :  { type: Number, min: 18, index: true }\n      , bio   :  { type: String, match: /[a-z]/ }\n      , date  :  { type: Date, default: Date.now }\n      , buff  :  Buffer\n    });\n\n    // a setter\n    Comment.path('name').set(function (v) {\n      return capitalize(v);\n    });\n\n    // middleware\n    Comment.pre('save', function (next) {\n      notify(this.get('email'));\n      next();\n    });\n\nTake a look at the example in `examples/schema.js` for an end-to-end example of a typical setup.\n\n### Accessing a Model\n\nOnce we define a model through `mongoose.model('ModelName', mySchema)`, we can access it through the same function\n\n    var myModel = mongoose.model('ModelName');\n\nOr just do it all at once\n\n    var MyModel = mongoose.model('ModelName', mySchema);\n\nWe can then instantiate it, and save it:\n\n    var instance = new MyModel();\n    instance.my.key = 'hello';\n    instance.save(function (err) {\n      //\n    });\n\nOr we can find documents from the same collection\n\n    MyModel.find({}, function (err, docs) {\n      // docs.forEach\n    });\n\nYou can also `findOne`, `findById`, `update`, etc. For more details check out [the docs](http://mongoosejs.com/docs/queries.html).\n\n**Important!** If you opened a separate connection using `mongoose.createConnection()` but attempt to access the model through `mongoose.model('ModelName')` it will not work as expected since it is not hooked up to an active db connection. In this case access your model through the connection you created:\n\n    var conn = mongoose.createConnection('your connection string');\n    var MyModel = conn.model('ModelName', schema);\n    var m = new MyModel;\n    m.save() // works\n\n    vs\n\n    var conn = mongoose.createConnection('your connection string');\n    var MyModel = mongoose.model('ModelName', schema);\n    var m = new MyModel;\n    m.save() // does not work b/c the default connection object was never connected\n\n### Embedded Documents\n\nIn the first example snippet, we defined a key in the Schema that looks like:\n\n    comments: [Comments]\n\nWhere `Comments` is a `Schema` we created. This means that creating embedded documents is as simple as:\n\n    // retrieve my model\n    var BlogPost = mongoose.model('BlogPost');\n\n    // create a blog post\n    var post = new BlogPost();\n\n    // create a comment\n    post.comments.push({ title: 'My comment' });\n\n    post.save(function (err) {\n      if (!err) console.log('Success!');\n    });\n\nThe same goes for removing them:\n\n    BlogPost.findById(myId, function (err, post) {\n      if (!err) {\n        post.comments[0].remove();\n        post.save(function (err) {\n          // do something\n        });\n      }\n    });\n\nEmbedded documents enjoy all the same features as your models. Defaults, validators, middleware. Whenever an error occurs, it's bubbled to the `save()` error callback, so error handling is a snap!\n\nMongoose interacts with your embedded documents in arrays _atomically_, out of the box.\n\n### Middleware\n\nSee the [docs](http://mongoosejs.com/docs/middleware.html) page.\n\n#### Intercepting and mutating method arguments\n\nYou can intercept method arguments via middleware.\n\nFor example, this would allow you to broadcast changes about your Documents every time someone `set`s a path in your Document to a new value:\n\n    schema.pre('set', function (next, path, val, typel) {\n      // `this` is the current Document\n      this.emit('set', path, val);\n\n      // Pass control to the next pre\n      next();\n    });\n\nMoreover, you can mutate the incoming `method` arguments so that subsequent middleware see different values for those arguments. To do so, just pass the new values to `next`:\n\n    .pre(method, function firstPre (next, methodArg1, methodArg2) {\n      // Mutate methodArg1\n      next(\"altered-\" + methodArg1.toString(), methodArg2);\n    })\n\n    // pre declaration is chainable\n    .pre(method, function secondPre (next, methodArg1, methodArg2) {\n      console.log(methodArg1);\n      // => 'altered-originalValOfMethodArg1' \n      \n      console.log(methodArg2);\n      // => 'originalValOfMethodArg2' \n      \n      // Passing no arguments to `next` automatically passes along the current argument values\n      // i.e., the following `next()` is equivalent to `next(methodArg1, methodArg2)`\n      // and also equivalent to, with the example method arg \n      // values, `next('altered-originalValOfMethodArg1', 'originalValOfMethodArg2')`\n      next();\n    })\n\n#### Schema gotcha\n\n`type`, when used in a schema has special meaning within Mongoose. If your schema requires using `type` as a nested property you must use object notation:\n\n    new Schema({\n        broken: { type: Boolean }\n      , asset : {\n            name: String\n          , type: String // uh oh, it broke. asset will be interpreted as String\n        }\n    });\n\n    new Schema({\n        works: { type: Boolean }\n      , asset : {\n            name: String\n          , type: { type: String } // works. asset is an object with a type property\n        }\n    });\n\n### Driver access\n\nThe driver being used defaults to [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) and is directly accessible through `YourModel.collection`. **Note**: using the driver directly bypasses all Mongoose power-tools like validation, getters, setters, hooks, etc.\n\n## API Docs\n\nFind the API docs [here](http://mongoosejs.com/docs/api.html), generated using [dox](http://github.com/visionmedia/dox).\n\n## License\n\nCopyright (c) 2010 LearnBoost &lt;dev@learnboost.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
  "readmeFilename": "README.md",
  "_id": "mongoose@3.8.4",
  "dist": {
    "shasum": "56df88bbffb649e6336ef44a4fc4c3dc215d63f2"
  },
  "_from": "mongoose@",
  "_resolved": "https://registry.npmjs.org/mongoose/-/mongoose-3.8.4.tgz"
}
