Skip to content

Instantly share code, notes, and snippets.

@hpeinar
Created November 19, 2012 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpeinar/4109931 to your computer and use it in GitHub Desktop.
Save hpeinar/4109931 to your computer and use it in GitHub Desktop.
module.exports = function(sequelize, DataTypes) {
return sequelize.define('user_roles', {
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
userId: { type: DataTypes.INTEGER },
roleId: { type: DataTypes.INTEGER },
schoolId: { type: DataTypes.INTEGER },
councilId: { type: DataTypes.INTEGER },
classId: { type: DataTypes.INTEGER },
active: { type: DataTypes.BOOLEAN },
created: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },
}, {
timestamps: false,
freezeTableName: true,
classMethods: {
getUserActiveRole : function(userId, callback) {
this.find({where: {userId: userId, active: true}}).success(function(activeRole) {
callback(activeRole);
})
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment