29 lines
757 B
JavaScript
29 lines
757 B
JavaScript
module.exports = mongoose => {
|
|
var editHistorySchema = mongoose.Schema({
|
|
employee: String,
|
|
date: Date
|
|
});
|
|
|
|
var schema = mongoose.Schema(
|
|
{
|
|
customer_id: String,
|
|
customer_name: String,
|
|
date: String,
|
|
has_snack: Boolean,
|
|
create_by: String,
|
|
create_date: Date,
|
|
edit_history: [{
|
|
type: editHistorySchema
|
|
}],
|
|
site: Number
|
|
},
|
|
{ collection: 'snack', timestamps: true }
|
|
);
|
|
schema.method("toJSON", function() {
|
|
const { __v, _id, ...object } = this.toObject();
|
|
object.id = _id;
|
|
return object;
|
|
});
|
|
const Snack = mongoose.model("snack", schema);
|
|
return Snack;
|
|
}; |