'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const Present = { name: { type: String, required: true, maxLength: 200 }, // 礼物名称 price: { type: String, required: true, maxLength: 200 }, // 金额 }; const schema = new Schema(Present, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('present', schema, 'present'); };