20 lines
622 B
JavaScript
20 lines
622 B
JavaScript
const uniqueValidator = require('mongoose-unique-validator');
|
|
module.exports = mongoose => {
|
|
var schema = mongoose.Schema(
|
|
{
|
|
phone_title: String,
|
|
phone_number: String,
|
|
activated: Boolean,
|
|
site: Number
|
|
},
|
|
{ collection: 'center_phone', timestamps: true }
|
|
);
|
|
schema.method("toJSON", function() {
|
|
const { __v, _id, ...object } = this.toObject();
|
|
object.id = _id;
|
|
return object;
|
|
});
|
|
schema.plugin(uniqueValidator);
|
|
const CenterPhone = mongoose.model("center_phone", schema);
|
|
return CenterPhone;
|
|
}; |