Update: Models
This commit is contained in:
parent
70ca726122
commit
002f79851a
10 changed files with 55 additions and 71 deletions
49
app-backend/models/database/users.model.js
Normal file
49
app-backend/models/database/users.model.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
const roles = require("../../config/role.config");
|
||||
|
||||
module.exports = mongoose => {
|
||||
let schema = mongoose.Schema({
|
||||
email: String,
|
||||
hashPass: String, // WARNING: We don't want to send back the hashPass
|
||||
login: String,
|
||||
role: {
|
||||
type: Object,
|
||||
default: roles.User
|
||||
},
|
||||
company: String,
|
||||
profilePictureUrl: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
dateOfBirth: {
|
||||
type: Date,
|
||||
default: null
|
||||
},
|
||||
gender: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
interests: {
|
||||
type: Array,
|
||||
default: null
|
||||
},
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
isAccepted: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
lastConnexion: Date
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
schema.method("toJSON", function() {
|
||||
const { __v, _id, ...object } = this.toObject();
|
||||
object.id = _id;
|
||||
return object;
|
||||
});
|
||||
|
||||
return mongoose.model("users", schema);
|
||||
};
|
||||
Reference in a new issue