shop.js 788 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 店铺表
  5. const shop = {
  6. name: { type: String, required: false, zh: '店铺名称' }, //
  7. notice: { type: String, required: false, zh: '公告内容' }, //
  8. money: { type: Number, required: false, zh: '餐位费' }, //
  9. logo: { type: Array, zh: '首页图片' }, // 附件
  10. };
  11. const schema = new Schema(shop, {
  12. toJSON: { getters: true, virtuals: true },
  13. });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.index({ name: 1 });
  17. schema.index({ notice: 1 });
  18. schema.index({ money: 1 });
  19. schema.plugin(metaPlugin);
  20. module.exports = app => {
  21. const { mongoose } = app;
  22. return mongoose.model('Shop', schema, 'shop');
  23. };