Built motion from commit 95b01fa.|0.0.70
[motion.git] / server / models / voice_recording.js
1 /* jshint indent: 2 */
2 var moment = require('moment');
3
4 module.exports = function(sequelize, DataTypes) {
5   var VoiceRecording = sequelize.define('VoiceRecording', {
6     uniqueid: {
7       type: DataTypes.STRING,
8       primaryKey: true
9     },
10     channel: {
11       type: DataTypes.STRING
12     },
13     calleridnum: {
14       type: DataTypes.STRING
15     },
16     calleridname: {
17       type: DataTypes.STRING
18     },
19     connectedlinenum: {
20       type: DataTypes.STRING
21     },
22     connectedlinename: {
23       type: DataTypes.STRING
24     },
25     language: {
26       type: DataTypes.STRING
27     },
28     accountcode: {
29       type: DataTypes.STRING
30     },
31     context: {
32       type: DataTypes.STRING
33     },
34     exten: {
35       type: DataTypes.STRING
36     },
37     value: {
38       type: DataTypes.STRING
39     },
40     type: {
41       type: DataTypes.STRING
42     },
43     rating: {
44       type: DataTypes.INTEGER,
45       defaultValue: 0,
46       validate: {
47         max: 5,
48         min: 0
49       }
50     },
51     createdAt: {
52       type: DataTypes.DATE,
53       get: function() {
54         // 'this' allows you to access attributes of the instance
55         return moment(this.getDataValue('agentconnectAt')).format("MM-DD-YYYY HH:mm");
56       }
57     },
58     updatedAt: {
59       type: DataTypes.DATE,
60       get: function() {
61         // 'this' allows you to access attributes of the instance
62         return moment(this.getDataValue('agentconnectAt')).format("MM-DD-YYYY HH:mm");
63       }
64     }
65   }, {
66     tableName: 'voice_recordings',
67     associate: function(models) {
68       // VoiceRecording.belongsTo(models.ReportCall, {
69       //   foreignKey: 'uniqueid'
70       // });
71     }
72   });
73
74   return VoiceRecording;
75 };