worldshine-redesign/app/models/sent-message.model.js
2025-04-14 16:29:36 -04:00

26 lines
758 B
JavaScript

const uniqueValidator = require('mongoose-unique-validator');
module.exports = mongoose => {
var schema = mongoose.Schema(
{
from_type: String,
from: String,
to_type: String,
to: String,
department: String,
content: String,
status: String,
create_by: String,
create_date: Date,
site: Number
},
{ collection: 'message', timestamps: true }
);
schema.method("toJSON", function() {
const { __v, _id, ...object } = this.toObject();
object.id = _id;
return object;
});
schema.plugin(uniqueValidator);
const SentMessage = mongoose.model("sentMessage", schema);
return SentMessage;
};