26 lines
696 B
JavaScript
26 lines
696 B
JavaScript
module.exports = mongoose => {
|
|
var schema = mongoose.Schema(
|
|
{
|
|
username: String,
|
|
email: String,
|
|
salt: Number,
|
|
password: String,
|
|
api_token: String,
|
|
roles: [{
|
|
type: String
|
|
}],
|
|
status: String,
|
|
create_by: String,
|
|
create_date: Date,
|
|
site: Number
|
|
},
|
|
{ collection: 'user', timestamps: true }
|
|
);
|
|
schema.method("toJSON", function() {
|
|
const { __v, _id, ...object } = this.toObject();
|
|
object.id = _id;
|
|
return object;
|
|
});
|
|
const User = mongoose.model("user", schema);
|
|
return User;
|
|
}; |