questionnaire.js 721 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 问卷表
  5. const QuestionnaireSchema = {
  6. name: { type: String, required: true, maxLength: 200 }, // 问卷名称
  7. num: { type: String, required: true, maxLength: 200 }, // 序号
  8. status: { type: String, required: true, maxLength: 200, defalut: 0 }, // 状态0、开启1、关闭
  9. question: [ String ], // 问题code
  10. };
  11. const schema = new Schema(QuestionnaireSchema, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Questionnaire', schema, 'questionnaire');
  17. };