'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 创新劵审核记录表 const ticket_record = { ticket_id: { type: ObjectId }, opera_id: { type: ObjectId }, // 审核人 status: { type: String }, // 改变为的状态 desc: { type: String }, // 建议 remark: { type: String }, create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') }, }; const schema = new Schema(ticket_record, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ ticket_id: 1 }); schema.index({ status: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Ticket_record', schema, 'ticket_record'); };