Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):
class Shop extends Eloquent {}
Using custom table name
protected $table = 'my_shops';
| var Q = require('q'); | |
| var Sequelize = require('sequelize'); | |
| var sequelize = new Sequelize('test', 'root', 'root'); | |
| function sequelizeQuery(query) { | |
| var deferred = Q.defer(); | |
| sequelize.query(query).on('success',deferred.resolve).on('failure', ?); | |
| return deferred.promise; | |
| } |
| DB.Tasks.findAll( | |
| {where: | |
| {status:'PENDING'} | |
| }, | |
| {limit:10} | |
| ).success(function(tasks){ | |
| tasks.updateAttributes({'status':'IN-PROGRESS'}).success(function(){}); | |
| }) |
| var myLibrary = (function(){ | |
| this.PublicFunction = function(){ | |
| }; | |
| this.PublicFunction = function(){ | |
| }; | |
| }); |
| 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){ |