12345678910111213141516171819202122232425 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 店铺表
- const shop = {
- name: { type: String, required: false, zh: '店铺名称' }, //
- notice: { type: String, required: false, zh: '公告内容' }, //
- money: { type: Number, required: false, zh: '餐位费' }, //
- logo: { type: Array, zh: '首页图片' }, // 附件
- };
- const schema = new Schema(shop, {
- toJSON: { getters: true, virtuals: true },
- });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ name: 1 });
- schema.index({ notice: 1 });
- schema.index({ money: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Shop', schema, 'shop');
- };
|