12345678910111213141516171819202122232425262728293031323334 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const persons = [{
- customer: '用户',
- status: '状态', // 0:入团;1:退团
- join_time: '入团时间',
- out_time: '退团时间',
- }];
- // 团表
- const group = {
- shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
- goods: { type: Object, required: false, zh: '商品' }, //
- goodsSpec: { type: Object, required: false, zh: '规格' }, //
- leader: { type: String, required: false, zh: '团长', ref: 'User.User' }, //
- persons: { type: Array, required: false, zh: '团员' }, //
- status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:group_status
- person_limit: { type: Number, required: false, zh: '人数限制' }, //
- };
- const schema = new Schema(group, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ shop: 1 });
- schema.index({ goods: 1 });
- schema.index({ goodsSpec: 1 });
- schema.index({ leader: 1 });
- schema.index({ status: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Group', schema, 'group');
- };
|