Skip to content

Instantly share code, notes, and snippets.

@abishekrsrikaanth
Forked from mickhansen/gist:8187691
Last active January 1, 2016 19:08
Show Gist options
  • Save abishekrsrikaanth/8188012 to your computer and use it in GitHub Desktop.
Save abishekrsrikaanth/8188012 to your computer and use it in GitHub Desktop.
Transactings.findAll({
where: {
status: 'PENDING'
},
include: [Account]
}).done(function (err, transactings) {
async.forEach(transactings, function (transacting, callback) {
restler.post('http://someurl/getTransactionInfo',data:{
tx_id: transacting.id
}).on('complete',function(data,response){
sequelize.transaction(function(t) {
var chainer = new Sequelize.QueryChainer()
chainer.add(transacting.account.increment('balanace', transacting.amount))
chainer.add(Transaction.create({amount: transacting.amount}))
chainer.error(t.rollback)
chainer.success(t.commit)
t.done(callback)
});
});
}, function () {
// Were done
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment