Skip to content

Instantly share code, notes, and snippets.

View mickhansen's full-sized avatar

Mick Hansen mickhansen

  • Copenhagen, Denmark
View GitHub Profile
Transactings.findAll({
where: {
status: 'PENDING'
},
include: [Account]
}).done(function (err, transactings) {
async.forEach(transactings, function (transacting, callback) {
sequelize.transaction(function(t) {
var chainer = new Sequelize.QueryChainer()
var User = sequelize.define('User', {
});
User.classMethod = function() {}
User.prototype.instanceMethod = function() {}
var user = new User(values, options); // Build
Physician.hasMany(Appointment)
Physician.hasMany(Patient, {through: Appointment})
Patient.hasMany(Appointment)
Patient.hasMany(Physician, {through: Appointment})
try {
var j = JSON.parse(fullData);
console.log(j);
if(j.errors || j.error) {
j.arguments = used_args;
return callback(j, null);
}
callback(null, j);
} catch(e) {
callback({
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
models.User.find(id).done(function (err, user) {
done(err, user);
});
});
var Sequelize = require('sequelize'),
DAO = require('sequelize/lib/dao'),
_increment = DAO.prototype.increment,
_decrement = DAO.prototype.decrement;
DAO.prototype.increment = function(field, options) {
var instance = this,
by = (options && options.by) || options || 1;
instance.set(field, instance.get(field) + by);
// Generated by CoffeeScript 1.7.1
(function() {
var AREAS, DAMAGE_MAX, Employee, Location, Report, Sequelize, arg, async, sequelize, start;
Sequelize = require('./index');
async = require('async');
AREAS = ['area1', 'area2', 'area3'];
SELECT "Comics".*,
"Favourites"."id" AS "Favourites.id",
"Favourites"."createdAt" AS "Favourites.createdAt",
"Favourites"."updatedAt" AS "Favourites.updatedAt",
"Favourites"."UserId" AS "Favourites.UserId",
"Favourites"."ComicId" AS "Favourites.ComicId"
FROM (
SELECT "Comics".* FROM "Comics" ORDER BY "number" DESC LIMIT 60
) AS "Comics"
LEFT OUTER JOIN "Favourites" AS "Favourites"
var Promise = require('bluebird');
Promise.reduce(queries, function (results, query) {
return sequelize.query(query, null, {raw: true, plain: true}).then(function (result) {
return results.concat([result]);
});
}, []).then(function (results) {
console.log("results");
}).catch(function (err) {
console.error("Error": err);
});
var deviceToSave = Device.build({});
Device.findOrCreate({
where: {device_id: deviceToSave.device_id},
defaults: deviceToSave.get()
}).spread(function(device, created) {
if (created) return device;
return device.updateAttributes(deviceToSave.get());
}).then(function (item) {
response.code(201).send(item.get());