Built motion from commit c56b56e.|0.0.125
[motion.git] / server / models / analytics_extracted_report.js
1 /**
2  * tag Model
3  */
4 var moment = require('moment');
5
6 module.exports = function(sequelize, DataTypes) {
7
8   var ExtractedReport = sequelize.define('ExtractedReport', {
9     name: DataTypes.STRING,
10     output: DataTypes.STRING, //csv,pdf,..
11     savename: DataTypes.STRING,
12     startDate: {
13       type: DataTypes.DATE,
14       get: function() {
15         // 'this' allows you to access attributes of the instance
16         return moment(this.getDataValue('startDate')).format("YYYY-MM-DD HH:mm");
17       }
18     },
19     endDate: {
20       type: DataTypes.DATE,
21       get: function() {
22         // 'this' allows you to access attributes of the instance
23         return moment(this.getDataValue('endDate')).format("YYYY-MM-DD HH:mm");
24       }
25     },
26     status: {
27       type: DataTypes.STRING,
28       defaultValue: 'Loading'
29     },
30     createdAt: {
31       type: DataTypes.DATE,
32       get: function() {
33         // 'this' allows you to access attributes of the instance
34         return moment(this.getDataValue('createdAt')).format("YYYY-MM-DD HH:mm:ss");
35       }
36     },
37     type: {
38       type: DataTypes.STRING,
39       defaultValue: 'manual'
40     },
41     UserId: DataTypes.INTEGER
42   }, {
43     tableName: 'analytics_extracted_reports',
44     associate: function(models) {
45       ExtractedReport.belongsTo(models.MailMessage);
46     }
47   });
48
49   return ExtractedReport;
50 };