3 module.exports = function(sequelize, DataTypes) {
4 return sequelize.define('ReportJscriptyQuestion', {
5 question_id: DataTypes.INTEGER,
6 question_type: DataTypes.STRING,
7 question_label: DataTypes.STRING,
8 question_text: DataTypes.STRING,
9 question_answer: DataTypes.STRING,
10 question_other_label: DataTypes.STRING,
11 question_other_answer: DataTypes.STRING,
12 question_options: DataTypes.STRING,
13 index: DataTypes.INTEGER
15 tableName: 'report_jscripty_questions',
16 associate: function(models) {
17 models.ReportJscriptyQuestion.hasMany(models.ReportJscriptyInput, {
19 foreignKey: 'questionId'
22 models.ReportJscriptyQuestion.addScope('otherOption', function(projectId, questionId) {
26 question_id: questionId,
27 question_type: 'question',
28 question_other_answer: {
32 attributes: ['question_type', 'question_id', 'question_label', 'question_text', 'question_other_label', 'question_other_answer'],
36 models.ReportJscriptyQuestion.addScope('summary', function(projectId) {
49 attributes: ['question_id', 'question_type', 'question_label', 'question_text', [sequelize.fn('count', sequelize.col('question_id')), 'count']],
53 group: ['question_id']