'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); // 购物车表 const cart = { list: { type: Array, zh: '购买商品' }, // total: { type: Number, zh: '总价' }, // table: { type: String, zh: '桌号' }, // }; const schema = new Schema(cart, { toJSON: { getters: true, virtuals: true }, }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Cart', schema, 'cart'); };