'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 系统通知表 const notice = { customer: { type: String, required: true, zh: '用户', ref: 'User.User' }, // time: { type: String, required: false, zh: '发送时间' }, // content: { type: String, required: false, zh: '内容' }, // status: { type: String, required: false, zh: '状态' }, // 字典:notice_status }; const schema = new Schema(notice, { toJSON: { getters: true, virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ customer: 1 }); schema.index({ status: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Notice', schema, 'notice'); };