12345678910111213141516171819202122232425262728293031 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 店铺系统消息
- const shopNotice = {
- shop: { type: String, required: false, zh: '店铺' }, //
- source: { type: String, required: false, zh: '消息来源' }, // 字典:notice_source
- source_type: { type: String, required: false, zh: '消息类型' }, // 字典:notice_source_type
- source_id: { type: String, required: false, zh: '来源id' }, //
- time: { type: String, required: false, zh: '发送时间' }, //
- content: { type: String, required: false, zh: '内容' }, //
- type: { type: String, required: false, default: '1', zh: '发送类型' }, // 字典:notice_type;只是显示;默认:人为发送
- status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:notice_status
- };
- const schema = new Schema(shopNotice, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ shop: 1 });
- schema.index({ source: 1 });
- schema.index({ source_id: 1 });
- schema.index({ time: 1 });
- schema.index({ type: 1 });
- schema.index({ status: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('ShopNotice', schema, 'shopNotice');
- };
|