const uniqueValidator = require('mongoose-unique-validator');
module.exports = mongoose => {
    var schema = mongoose.Schema(
        {
            message_name: String,
            message_group: Number,
            language: String,
            message_body: String,
            message_title: String,
            site: Number
        },
        { collection: 'message_template', timestamps: true }
      );
    schema.method("toJSON", function() {
        const { __v, _id, ...object } = this.toObject();
        object.id = _id;
        return object;
      });
    schema.plugin(uniqueValidator);
    const Message = mongoose.model("message", schema);
    return Message;
  };