Checkoutthe[pluginssearchsite](http://plugins.mongoosejs.io/) to see hundreds of related modules from the community. Next, learn how to write your own plugin from the [docs](http://mongoosejs.com/docs/plugins.html) or [this blog post](http://thecodebarbarian.com/2015/03/06/guide-to-mongoose-plugins).
##Contributors
Viewall300+[contributors](https://github.com/Automattic/mongoose/graphs/contributors). Stand up and be counted as a [contributor](https://github.com/Automattic/mongoose/blob/master/CONTRIBUTING.md) too!
##Installation
Firstinstall[node.js](http://nodejs.org/) and [mongodb](https://www.mongodb.org/downloads). Then:
```sh
$npminstallmongoose
```
##Stability
Thecurrentstablebranchis[master](https://github.com/Automattic/mongoose/tree/master). The [3.8.x](https://github.com/Automattic/mongoose/tree/3.8.x) branch contains legacy support for the 3.x release series, which is no longer under active development as of September 2015. The [3.8.x docs](http://mongoosejs.com/docs/3.8.x/) are still available.
##Overview
###ConnectingtoMongoDB
First,weneedtodefineaconnection.Ifyourappusesonlyonedatabase,youshoulduse`mongoose.connect`. If you need to create additional connections, use `mongoose.createConnection`.
Both`connect` and `createConnection` take a `mongodb://` URI, or the parameters `host, database, port, options`.
Onceconnected,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`.
**Important!**Ifyouopenedaseparateconnectionusing`mongoose.createConnection()` but attempt to access the model through `mongoose.model('ModelName')`itwillnotworkasexpectedsinceitisnothookeduptoanactivedbconnection.Inthiscaseaccessyourmodelthroughtheconnectionyoucreated:
Moreover,youcanmutatetheincoming`method` arguments so that subsequent middleware see different values for those arguments. To do so, just pass the new values to `next`:
`type`, when used in a schema has special meaning within Mongoose. If your schema requires using `type`asanestedpropertyyoumustuseobjectnotation:
```js
newSchema({
broken:{type:Boolean},
asset:{
name:String,
type:String// uh oh, it broke. asset will be interpreted as String
}
});
newSchema({
works:{type:Boolean},
asset:{
name:String,
type:{type:String}// works. asset is an object with a type property
}
});
```
###DriverAccess
Mongooseisbuiltontopofthe[officialMongoDBNode.jsdriver](https://github.com/mongodb/node-mongodb-native). Each mongoose model keeps a reference to a [native MongoDB driver collection](http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html). The collection object can be accessed using `YourModel.collection`. However, using the collection object directly bypasses all mongoose features, including hooks, validation, etc. The one