Releases: BesLogic/sails-mysql-atomic
Add support to pass commit data
Added support to do a transaction.commit(someData)
so the transaction.after.then(someData => ...)
gets resolved with the data passed on the commit. It also works when returning a value in the promise chain if we do not commit manually.
Fix model.beforeValidate in transaction
Added test coverage for each lifecycle callback methods to support transaction. The only one not yet supported is .afterValidate
. You can do logic in there, but nothing related to the current transaction.
Added support for deferred queries methods
The hook now supports mixing the query methods together using the transaction object:
.limit()
.populate()
.sort()
.skip()
.where()
SqlHelper.beginTransaction(transaction => {
return transaction.forModel(Dog)
.create([
{ name: 'fido' },
{ name: 'skippy', bones: [{size:'small'}, {size:'large'}] },
{ name: 'peanut' }
])
.then(() => transaction.forModel(Dog)
.find({})
.populate('bones')
.sort('name ASC')
.where({name:'skippy'}))
.then(results => {
results.length.should.be.equal(1);
results[0].name.should.be.equal('skippy');
results[0].bones.length.should.be.equal(2);
})
.then(() => done())
.catch(done);
});
Fix support for nested and deeply nested operations
Fixed context injection for nested operations so we can pass the database connection when creating nested associations.
See example in my test:
https://github.com/BesLogic/sails-mysql-atomic/blob/master/test/transactions.spec.js#L592
Fix support for missed query methods
Added missing test to support .findOrCreate(...)
under transaction
Code Cleanup
Simplified the logic by passing along the connection instead of an ID to lookup for the connection.
Major rework to scope transaction in promise context
This release fixes the support for many-to-many associations created or deleted within a transaction.
Example:
https://github.com/BesLogic/sails-mysql-atomic/blob/master/test/transactions.spec.js#L296
Repo renaming
One more step. This repo has been renamed from sails-mysql-transactions-helper
to sails-mysql-atomic
to avoid confusion with sails-mysql-transactions
Breaking changes
- The adapter has been renamed from
sails-mysql-transactional
tosails-mysql-atomic
- The hook usage has been changed to
sails.hooks['sails-mysql-atomic'].beginTransaction(...);
(which is shorter to type :]) - The npm repo has been updated as well to match the new name: https://www.npmjs.com/package/sails-mysql-atomic
Published to npm
This hook is now available through npm using npm install sails-mysql-transactions-helper
Breaking change:
The name of the package has changed from mysql-transactions-helper
to sails-mysql-transactions-helper
so the usage in you project has changed to match the hook name:
sails.hooks['sails-mysql-transactions-helper'].beginTransaction(...);
https://github.com/BesLogic/sails-mysql-transactions-helper#how-to-use-it-in-your-project
Fixed adapter identity typo
One more breaking change:
- The database adapter name has changed from
sails-mysql-transactionnal
tosails-mysql-transactional