sequelize/sequelize — pull request #872 by dvorakroth (2013-09-01 19:58:41+00:00)
Title: Added basic Express middleware

Needs work, but it's a start.

Usage:
```javascript

Sequelize = require('sequelize')
app = require('express')()

app.use(Sequelize.express(my_connection_string, __dirname + "/models.js"))
```

Basically, `Sequelize.express` receives the same arguments as `new Sequelize`, with the addition of the last argument, called `models_callback`, which can be:

* A string representing the filename to pass on to the `import` method; or
* A function of the form `function(sequelize, dataTypes) {...}`

To use your DB connection in a request:

```javascript

app.get('/posts/:id', function(req, res, next) {
req.models.Post.find({where: {id: req.params.id}}).success(function(post) {
res.render(...)
}).error(function(err) {
res.render(...)
})
})
```

where `req.models` is the exact same value returned by the `models_callback` mentioned above.