1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 问卷回答表
- const answer = {
- questionnaire_id: { type: ObjectId }, // 问卷id
- answer: { type: Array }, // 答案
- user_id: { type: ObjectId },//用户id
- phone: { type: String },//电话
- contacts: { type: String },//联系人
- company: { type: String },//企业名称
- address: { type: String },//联系地址
- attribute: { type: String },//企业属性
- category: { type: String },//产品类别
- remark: { type: String, maxLength: 200 },
- create_time: {
- type: String,
- default: moment(new Date()).format("YYYY-MM-DD HH:mm:ss"),
- },
- };
- const schema = new Schema(answer, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ questionnaire_id: 1 });
- schema.index({ user_id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Answer', schema, 'answer');
- };
|