survey.js 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
  6. const { ObjectId } = require('mongoose').Types;
  7. // 建言献策,网上调查表
  8. const survey = {
  9. user_id: { type: ObjectId, required: false, maxLength: 500 }, // 用户id
  10. // 网上调查
  11. resource: { type: String, required: false, maxLength: 500 }, // 是否愿意
  12. // 建议
  13. nickname: { type: String, required: false, maxLength: 500 }, // 昵称
  14. name: { type: String, required: false, maxLength: 500 }, // 姓名
  15. phone: { type: String, required: false, maxLength: 500 }, // 手机号
  16. work: { type: String, required: false, maxLength: 500 }, // 职业
  17. address: { type: String, required: false, maxLength: 500 }, // 详细地址
  18. title: { type: String, required: false, maxLength: 500 }, // 标题
  19. proposal: { type: String, required: false, maxLength: 500 }, // 建议内容
  20. remark: { type: String, maxLength: 200 },
  21. create_time: { type: String },
  22. };
  23. const schema = new Schema(survey, { toJSON: { virtuals: true } });
  24. schema.index({ id: 1 });
  25. schema.index({ user_id: 1 });
  26. schema.index({ 'meta.createdAt': 1 });
  27. schema.plugin(metaPlugin);
  28. module.exports = app => {
  29. const { mongoose } = app;
  30. return mongoose.model('Survey', schema, 'survey');
  31. };