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
  • Greenlyst Inc.
  • Bangalore, India
View GitHub Profile

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

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){
@abishekrsrikaanth
abishekrsrikaanth / mylib.js
Created January 8, 2014 02:41
Node JS Module definition
var myLibrary = (function(){
this.PublicFunction = function(){
};
this.PublicFunction = function(){
};
});
DB.Tasks.findAll(
{where:
{status:'PENDING'}
},
{limit:10}
).success(function(tasks){
tasks.updateAttributes({'status':'IN-PROGRESS'}).success(function(){});
})
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;
}
Employees.find({where:{role:'MANAGER'}}).max('age').on('success',function(){
});
C:\Users\Abishek\Documents\GitHub\sequelize>mocha -g "updates with function and column value" -t 10000 test/dao-factory-test.js
C:\Users\Abishek\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:432
if (!files.length) throw new Error("cannot resolve path (or pattern) '"
^
Error: cannot resolve path (or pattern) 'test/dao-factory-test.js'
at lookupFiles (C:\Users\Abishek\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:432:32)
at runAgain (C:\Users\Abishek\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:284:24)
at Array.forEach (native)
at Object.<anonymous> (C:\Users\Abishek\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:283:6)
var AWS = require('aws-sdk');
AWS.config.update({accessKeyId: '{my_access_id}', secretAccessKey: '{my_secret_key}'});
var s3 = new AWS.S3();
var params = {
Bucket: 'bucket_name',
Key: key,
ACL: 'public-read',
Body: file_name
};
var Intimidate = require('intimidate');
var s3Uploader = function(options) {
try {
this.client = new Intimidate(options);
} catch (e) {
return null;
}
};
var Order = sequelize.define('Order',{
sale_net_price: Sequelize.DECIMAL(10, 2),
},{
underscored: true,
freezeTableName: true,
tableName: 'orders'
});
var Transaction = sequelize.define('Transaction',{
order_id: Sequelize.INTEGER,