Built motion from commit 1d6aa77.|0.0.94
[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       set: function(channel) {
13         if (channel) {
14           this.setDataValue('channel', channel);
15           this.setDataValue('membername', channel.split(/\/|-/)[1]);
16         }
17       }
18     },
19     membername: {
20       type: DataTypes.STRING
21     },
22     calleridnum: {
23       type: DataTypes.STRING
24     },
25     calleridname: {
26       type: DataTypes.STRING
27     },
28     connectedlinenum: {
29       type: DataTypes.STRING
30     },
31     connectedlinename: {
32       type: DataTypes.STRING
33     },
34     language: {
35       type: DataTypes.STRING
36     },
37     accountcode: {
38       type: DataTypes.STRING
39     },
40     context: {
41       type: DataTypes.STRING
42     },
43     exten: {
44       type: DataTypes.STRING
45     },
46     value: {
47       type: DataTypes.STRING
48     },
49     type: {
50       type: DataTypes.STRING
51     },
52     rating: {
53       type: DataTypes.INTEGER,
54       defaultValue: 0,
55       validate: {
56         max: 5,
57         min: 0
58       }
59     },
60     queue: {
61       type: DataTypes.STRING
62     },
63     createdAt: {
64       type: DataTypes.DATE,
65       get: function() {
66         // 'this' allows you to access attributes of the instance
67         return moment(this.getDataValue('createdAt')).format("MM-DD-YYYY HH:mm").toString();
68       }
69     },
70     updatedAt: {
71       type: DataTypes.DATE,
72       get: function() {
73         // 'this' allows you to access attributes of the instance
74         return moment(this.getDataValue('updatedAt')).format("MM-DD-YYYY HH:mm").toString();
75       }
76     }
77   }, {
78     tableName: 'voice_recordings',
79     associate: function(models) {
80       // VoiceRecording.belongsTo(models.ReportCall, {
81       //   foreignKey: 'uniqueid'
82       // });
83     }
84   });
85
86   return VoiceRecording;
87 };