'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 测试接口 const TestSchema = { name: { type: String, required: true, maxLength: 200 }, // 姓名 mobile: { type: String, required: true, maxLength: 200 }, // 电话 qqwx: { type: String, required: true, maxLength: 200 }, // qq/微信 email: { type: String, required: true, maxLength: 200 }, // 电子邮箱 address: { type: String, required: true, maxLength: 200 }, // 联系地址 }; const schema = new Schema(TestSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Test', schema, 'test'); };