2 var moment = require('moment');
4 module.exports = function(sequelize, DataTypes) {
5 return sequelize.define('ReportJscriptySession', {
7 type: DataTypes.INTEGER,
12 type: DataTypes.ENUM('started', 'completed', 'incomplete')
14 last_question_id: DataTypes.INTEGER,
18 // 'this' allows you to access attributes of the instance
19 return this.getDataValue('completedAt') ? moment(this.getDataValue('completedAt')).format("MM-DD-YYYY HH:mm") : '';
25 // 'this' allows you to access attributes of the instance
26 return moment(this.getDataValue('createdAt')).format("MM-DD-YYYY HH:mm");
30 tableName: 'report_jscripty_sessions',
31 associate: function(models) {
32 models.ReportJscriptySession.hasMany(models.ReportJscriptyQuestion, {
34 foreignKey: 'sessionId'
36 models.ReportJscriptySession.addScope('questionsAndInput', function(projectId) {
42 model: models.ReportJscriptyQuestion,
44 model: models.ReportJscriptyInput