storeShop.js 777 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 storeShop = {
  6. customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
  7. shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
  8. time: { type: String, required: false, zh: '时间' }, //
  9. };
  10. const schema = new Schema(storeShop, { toJSON: { getters: true, virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.index({ 'meta.createdAt': 1 });
  13. schema.index({ customer: 1 });
  14. schema.index({ shop: 1 });
  15. schema.index({ time: 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('StoreShop', schema, 'storeShop');
  20. };