sequelize/sequelize — pull request #1062 by sdepold (2013-11-18 20:39:45+00:00)
Title: Transactions

This pull request adds transaction support.

The transaction flow can be controlled like this:

```js
sequelize.transaction(function(t) {
// we just opened a new connection to the database which is transaction exclusive.
// also we send some first transaction queries to the database.

// do some async stuff ...

// if everything is ok ... commit the transaction
t.commit().success(function() {})

// if something failed ... rollback the transaction
t.rollback().success(function() {})

// the commit / rollback will emit events which can be observed via:
t.done(function() {
/* we will be here once the transaction
has been committed / reverted */
})
})
```

In order to execute queries inside the transaction, the options parameter of DAOFactory/DAO methods accepts the transaction key:

```js
sequelize.transaction(function(t) {
User.create({ username: 'foo' }, { transaction: t }).success(function() {
// this user will only be available inside the session
User.all({ transaction: t }) // will return the user
User.all() // will not return the user
})
})
```

This PR also adds `Utils.validateParameter` which checks the existence of parameters and the data type integrity.