sails-hook-blocks
Version:
A Sails Micro-app architecture framework
41 lines (40 loc) • 793 B
JavaScript
module.exports = {
attributes: {},
associations() {
User.belongsToMany(Role, {
through: 'UserRole',
foreignKey: {
name: 'UserId',
as: 'Users',
},
});
Role.belongsToMany(User, {
through: 'UserRole',
foreignKey: {
name: 'RoleId',
as: 'Roles',
},
});
},
options: {
paranoid: false,
timestamps: true,
classMethods: {
...sails.config.models.classMethods.UserRole,
associations() {
return {
belongsTo: [],
hasMany: [],
hasOne: [],
belongsToMany: [],
};
},
},
instanceMethods: {
...sails.config.models.instanceMethods.UserRole,
},
hooks: {
...sails.config.models.hooks.UserRole,
},
},
};