-
Notifications
You must be signed in to change notification settings - Fork 1
/
users.model.js
64 lines (61 loc) · 1.16 KB
/
users.model.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
52
53
54
55
56
57
58
59
60
61
62
63
64
import sequelize from "../db";
import {
DataTypes
} from "sequelize";
import companyModel from "../Companies/company.model";
const userModel = sequelize.define("users", {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
auth0_id: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
role: {
type: DataTypes.STRING,
allowNull: false
},
full_name: {
type: DataTypes.STRING,
allowNull: false
},
profile_image: {
type: DataTypes.STRING
},
email: {
type: DataTypes.STRING,
unique: true,
allowNull: false
},
phone_number: {
type: DataTypes.STRING,
unique: true
},
approved_by_customer_admin: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
is_active: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
prefer_contact: {
type: DataTypes.ENUM,
values: ["phone_number", "email"],
defaultValue: "email",
},
});
companyModel.hasMany(userModel, {
foreignKey: {
name: "company_id",
allowNull: false
},
});
userModel.belongsTo(companyModel, {
foreignKey: "company_id",
});
userModel.sync();
export default userModel;