18 lines
562 B
JavaScript
18 lines
562 B
JavaScript
const uniqueValidator = require('mongoose-unique-validator');
|
|
module.exports = mongoose => {
|
|
var schema = mongoose.Schema(
|
|
{
|
|
message_token: String,
|
|
site: Number
|
|
},
|
|
{ collection: 'message_token', timestamps: true }
|
|
);
|
|
schema.method("toJSON", function() {
|
|
const { __v, _id, ...object } = this.toObject();
|
|
object.id = _id;
|
|
return object;
|
|
});
|
|
schema.plugin(uniqueValidator);
|
|
const MessageToken = mongoose.model("message_token", schema);
|
|
return MessageToken;
|
|
}; |