module.exports = mongoose => { var schema = mongoose.Schema( { date: String, seating_assignment: Object, create_by: String, create_date: Date, update_by: String, update_date: Date, site: Number }, { collection: 'seating', timestamps: true } ); schema.method("toJSON", function() { const { __v, _id, ...object } = this.toObject(); object.id = _id; return object; }); const Seating = mongoose.model("seating", schema); return Seating; };