module.exports = mongoose => { var schema = mongoose.Schema( { label_name: String, label_color: String, site: Number, status: String }, { collection: 'label', timestamps: true } ); schema.method("toJSON", function() { const { __v, _id, ...object } = this.toObject(); object.id = _id; return object; }); const Label = mongoose.model("label", schema); return Label; };