37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
module.exports = mongoose => {
|
|
var editHistorySchema = mongoose.Schema({
|
|
employee: String,
|
|
date: Date
|
|
});
|
|
var schema = mongoose.Schema(
|
|
{
|
|
name: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
content: String,
|
|
description: String,
|
|
model: Object,
|
|
status: String, // 'active', 'inactive'
|
|
file: [{
|
|
type: Object
|
|
}],
|
|
site: Number,
|
|
create_by: String,
|
|
create_date: Date,
|
|
edit_by: String,
|
|
edit_date: Date,
|
|
edit_history: [{
|
|
type: editHistorySchema
|
|
}],
|
|
},
|
|
{ collection: 'xlsx-template', timestamps: true }
|
|
);
|
|
schema.method("toJSON", function() {
|
|
const { __v, _id, ...object } = this.toObject();
|
|
object.id = _id;
|
|
return object;
|
|
});
|
|
const ExcelTemplate = mongoose.model("xlsxtemplate", schema);
|
|
return ExcelTemplate;
|
|
}; |