wprl/baucis — pull request #125 by PhilJ (2014-01-27 23:48:26+00:00)
Title: Pass custom mongoose connection as controller option

Allow to pass a mongoose connection to a baucis controller as a option, were the model is loaded from. Allows to use baucis in environments with mongoose instance shared over multiple modules. (Maybe also nice if you have an project with multiple mongoose connection)

*Example:*
```javascript
mongoose.connect('mongodb://...');
var connection = mongoose.connection;
baucis.rest({ singular: 'store', connection: connection });
```

**Why would you need that?**

I have a project setup for bauhausjs, where I use mongoose and baucis in different packages. However with such a setup you cannot benefit from mongoose global instance, so you have to share a instance yourself. I failed to get baucis working with that setup, because it requests the model from mongoose installed for the current module and I'm currently not able to pass my mongoose connection instance to baucis.

```
node_modules/
mongoose/
baucis/
furtherdependency/
node_modules/
mongoose/
baucis/
```

You can get around that issue easily by passing baucis an mongoose connection, to receive the model from by connection.model(), instead of just getting the model from mongoose.model().