-
Notifications
You must be signed in to change notification settings - Fork 19
/
user.js
51 lines (50 loc) · 1.16 KB
/
user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* User.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
attributes: {
name: {
type: Sequelize.STRING,
allowNull: false
},
age: {
type: Sequelize.INTEGER
}
},
associations: function() {
user.hasMany(image, {
onDelete: 'cascade',
as: 'images',
foreignKey: {
name: 'userId',
as: 'images',
allowNull: false
}
});
user.hasMany(pet, {
as: 'pets',
foreignKey: {
name: 'userId',
as: 'pets',
}
});
user.belongsToMany(affiliation, {
as: 'affiliations',
to: 'users', // must be named as the alias in the related Model
through: 'UserAffiliation',
foreignKey: {
name: 'userId',
as: 'affiliations'
}
});
},
options: {
tableName: 'user',
classMethods: {},
instanceMethods: {},
hooks: {}
}
};