1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 商品表
- const market = {
- mech_id: { type: ObjectId }, // 商户id
- mech_name: { type: String }, // 商户名称
- type: { type: String }, // 分类
- type_id: { type: ObjectId }, // 分类id
- name: { type: String }, // 商品名称
- brief: { type: String }, // 简介
- money: { type: Number }, // 单价
- img_url: { type: Array }, // 图片
- status: { type: String }, // 状态 【0:待上架,1:上架,2:下架,3:删除】
- remark: { type: String },
- };
- const schema = new Schema(market, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ mech_id: 1 });
- schema.index({ mech_name: 1 });
- schema.index({ type: 1 });
- schema.index({ type_id: 1 });
- schema.index({ name: 1 });
- schema.index({ money: 1 });
- schema.index({ status: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Market', schema, 'market');
- };
|