1234567891011121314151617181920212223 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 商品收藏
- const storeGoods = {
- customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
- goods: { type: String, required: false, zh: '商品', ref: 'Shop.Goods' }, //
- time: { type: String, required: false, zh: '时间' }, //
- };
- const schema = new Schema(storeGoods, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ customer: 1 });
- schema.index({ goods: 1 });
- schema.index({ time: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('StoreGoods', schema, 'storeGoods');
- };
|