'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { Secret } = require('naf-framework-mongoose-free/lib/model/schema'); const { ObjectId } = require('mongoose').Types; // 建言献策,网上调查表 const survey = { user_id: { type: ObjectId, required: false, maxLength: 500 }, // 用户id // 网上调查 resource: { type: String, required: false, maxLength: 500 }, // 是否愿意 // 建议 nickname: { type: String, required: false, maxLength: 500 }, // 昵称 name: { type: String, required: false, maxLength: 500 }, // 姓名 phone: { type: String, required: false, maxLength: 500 }, // 手机号 work: { type: String, required: false, maxLength: 500 }, // 职业 address: { type: String, required: false, maxLength: 500 }, // 详细地址 title: { type: String, required: false, maxLength: 500 }, // 标题 proposal: { type: String, required: false, maxLength: 500 }, // 建议内容 remark: { type: String, maxLength: 200 }, create_time: { type: String }, }; const schema = new Schema(survey, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ user_id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Survey', schema, 'survey'); };