123456789101112131415161718192021222324252627282930313233343536373839 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const reply = [{
- content: { type: String, zh: '内容' },
- time: { type: String, zh: '时间' },
- file: { type: Array, zh: '图片' },
- reply: { type: String, zh: '店家回复' },
- }];
- // 商品评价
- const goodsRate = {
- customer: { type: String, required: false, zh: '用户', ref: 'User.User' }, //
- orderDetail: { type: String, required: false, zh: '订单', ref: 'Trade.OrderDetail' }, //
- shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
- goods: { type: String, required: false, zh: '商品', ref: 'Shop.Goods' }, //
- goodsSpec: { type: String, required: false, zh: '规格', ref: 'Shop.GoodsSpec' }, //
- set_id: { type: String, required: false, zh: '套装id' },
- reply: { type: Array, required: false, zh: '回复' }, //
- goods_score: { type: Number, required: false, default: 5, zh: '商品评分' }, //
- shop_score: { type: Number, required: false, default: 5, zh: '服务评分' }, //
- transport_score: { type: Number, required: false, default: 5, zh: '快递评分' }, //
- };
- const schema = new Schema(goodsRate, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ customer: 1 });
- schema.index({ shop: 1 });
- schema.index({ goods: 1 });
- schema.index({ goodsSpec: 1 });
- schema.index({ orderDetail: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('GoodsRate', schema, 'goodsRate');
- };
|