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