storeGoods.js 784 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 商品收藏
  5. const storeGoods = {
  6. customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
  7. goods: { type: String, required: false, zh: '商品', ref: 'Shop.Goods' }, //
  8. time: { type: String, required: false, zh: '时间' }, //
  9. };
  10. const schema = new Schema(storeGoods, { toJSON: { getters: true, virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.index({ 'meta.createdAt': 1 });
  13. schema.index({ customer: 1 });
  14. schema.index({ goods: 1 });
  15. schema.index({ time: 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('StoreGoods', schema, 'storeGoods');
  20. };