Built motion from commit 82438f7.|0.0.115
[motion.git] / server / models / analytics_extracted_report.js
index 6a73b49..e3ed69e 100644 (file)
@@ -1,6 +1,7 @@
 /**
  * tag Model
  */
+var moment = require('moment');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -8,19 +9,41 @@ module.exports = function(sequelize, DataTypes) {
     name: DataTypes.STRING,
     output: DataTypes.STRING, //csv,pdf,..
     savename: DataTypes.STRING,
-    startDate: DataTypes.DATE,
-    endDate: DataTypes.DATE,
+    startDate: {
+      type: DataTypes.DATE,
+      get: function() {
+        // 'this' allows you to access attributes of the instance
+        return moment(this.getDataValue('startDate')).format("YYYY-MM-DD");
+      }
+    },
+    endDate: {
+      type: DataTypes.DATE,
+      get: function() {
+        // 'this' allows you to access attributes of the instance
+        return moment(this.getDataValue('endDate')).format("YYYY-MM-DD");
+      }
+    },
     status: {
       type: DataTypes.STRING,
       defaultValue: 'Loading'
-    }
+    },
+    createdAt: {
+      type: DataTypes.DATE,
+      get: function() {
+        // 'this' allows you to access attributes of the instance
+        return moment(this.getDataValue('createdAt')).format("YYYY-MM-DD HH:mm:ss");
+      }
+    },
+    type: {
+      type: DataTypes.STRING,
+      defaultValue: 'manual'
+    },
+    UserId: DataTypes.INTEGER
   }, {
     tableName: 'analytics_extracted_reports',
-    // associate: function(models) {
-    //   Tag.belongsToMany(models.Contact, {
-    //     through: 'contact_tags'
-    //   });
-    // }
+    associate: function(models) {
+      ExtractedReport.belongsTo(models.MailMessage);
+    }
   });
 
   return ExtractedReport;