Skip to content

Instantly share code, notes, and snippets.

View abishekrsrikaanth's full-sized avatar
🏠
Working from home

Abishek R Srikaanth abishekrsrikaanth

🏠
Working from home
View GitHub Profile
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(){});
})
@abishekrsrikaanth
abishekrsrikaanth / mylib.js
Created January 8, 2014 02:41
Node JS Module definition
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){

Conventions:

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';