b88fa55fa8c773a790db9d45c54aa85de7a3c3fd
[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("DD-MM-YYYY");
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("DD-MM-YYYY");
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("DD-MM-YYYY");
35       }
36     },
37   }, {
38     tableName: 'analytics_extracted_reports',
39     // associate: function(models) {
40     //   Tag.belongsToMany(models.Contact, {
41     //     through: 'contact_tags'
42     //   });
43     // }
44   });
45
46   return ExtractedReport;
47 };