'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const PresentRecord = { owner_id: { type: String, required: true, maxLength: 200 }, // 播主id owner_name: { type: String, required: true, maxLength: 200 }, // 播主名称 sender_id: { type: String, required: true, maxLength: 200 }, // 赠送人id sender_name: { type: String, required: true, maxLength: 200 }, // 赠送人名称 present_id: { type: String, required: true, maxLength: 200 }, // 礼物id present_name: { type: String, required: true, maxLength: 200 }, // 礼物名称 price: { type: String, required: true, maxLength: 200 }, // 金额 }; const schema = new Schema(PresentRecord, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('PresentRecord', schema, 'present_record'); };