This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Physician.hasMany(Appointment) | |
Physician.hasMany(Patient, {through: Appointment}) | |
Patient.hasMany(Appointment) | |
Patient.hasMany(Physician, {through: Appointment}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var User = sequelize.define('User', { | |
}); | |
User.classMethod = function() {} | |
User.prototype.instanceMethod = function() {} | |
var user = new User(values, options); // Build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A.findAll({ | |
include: [ | |
{model: B, include: [ | |
{model: C, include: [ | |
{model: D, include: [ | |
{model: E, include: [ | |
{model: F, include: [ | |
{model: G, include: [ | |
{model: H} | |
]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT "As".*, "B"."id" AS "B.id", "B"."createdAt" AS "B.createdAt", "B"."updatedAt" AS "B.updatedAt", "B"."CId" AS "B.CId", "B.C"."id" AS "B.C.id", "B.C"."createdAt" AS "B.C.createdAt", "B.C"."updatedAt" AS "B.C.updatedAt", "B.C"."DId" AS "B.C.DId", "B.C.D"."id" AS "B.C.D.id", "B.C.D"."createdAt" AS "B.C.D.createdAt", "B.C.D"."updatedAt" AS "B.C.D.updatedAt", "B.C.D"."EId" AS "B.C.D.EId", "B.C.D.E"."id" AS "B.C.D.E.id", "B.C.D.E"."createdAt" AS "B.C.D.E.createdAt", "B.C.D.E"."updatedAt" AS "B.C.D.E.updatedAt", "B.C.D.E"."FId" AS "B.C.D.E.FId", "B.C.D.E.F"."id" AS "B.C.D.E.F.id", "B.C.D.E.F"."createdAt" AS "B.C.D.E.F.createdAt", "B.C.D.E.F"."updatedAt" AS "B.C.D.E.F.updatedAt", "B.C.D.E.F"."GId" AS "B.C.D.E.F.GId", "B.C.D.E.F.G"."id" AS "B.C.D.E.F.G.id", "B.C.D.E.F.G"."createdAt" AS "B.C.D.E.F.G.createdAt", "B.C.D.E.F.G"."updatedAt" AS "B.C.D.E.F.G.updatedAt", "B.C.D.E.F.G"."HId" AS "B.C.D.E.F.G.HId", "B.C.D.E.F.G.H"."id" AS "B.C.D.E.F.G.H.id", "B.C.D.E.F.G.H"."createdAt" AS "B.C.D.E.F.G.H.createdAt", "B.C.D. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HasMany = function(source, target, options) { | |
var self = this | |
this.associationType = 'HasMany' | |
this.source = source | |
this.target = target | |
this.options = options | |
this.sequelize = source.daoFactoryManager.sequelize | |
this.through = options.through | |
this.isSelfAssociation = (this.source.tableName === this.target.tableName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Sequelize = require('sequelize'), | |
sequelize = new Sequelize('sequelize_test', 'sequelize_test', 'YDLvjZJv9GdvbM8G', { | |
logging: console.log | |
}); | |
var User = sequelize.define('User', {}), | |
Post = sequelize.define('Post', {}) | |
Post.belongsTo(User, {as: 'Creator', foreignKey: 'creator_id', foreignKeyConstraint: true}); | |
User.hasMany(Post, {foreignKey: 'creator_id'}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Sequelize = require('sequelize'), | |
sequelize = new Sequelize('sequelize_test', 'sequelize_test', 'YDLvjZJv9GdvbM8G', { | |
syncOnAssociation: false, | |
logging: console.log | |
}); | |
var User = sequelize.define('User', {}), | |
Post = sequelize.define('Post', {}), | |
SharedPosts = sequelize.define('SharedPosts', {}) |