6093d64297c65d2887e0aefe5fd77d339aac9686
[motion.git] / server / models / square_project.js
1 'use strict';
2
3 var _ = require('lodash');
4
5 module.exports = function(sequelize, DataTypes) {
6
7   var SquareProject = sequelize.define('SquareProject', {
8     name: {
9       type: DataTypes.STRING,
10       unique: true,
11       allowNull: false,
12       validate: {
13         notEmpty: true
14       }
15     },
16     description: DataTypes.STRING,
17     notes: DataTypes.TEXT,
18     preproduction: {
19       type: DataTypes.BLOB('long'),
20       get: function() {
21         if (this.getDataValue('preproduction')) {
22                                         return _.toString(this.getDataValue('preproduction'));
23                                 }
24       }
25     },
26     production: {
27       type: DataTypes.BLOB('long'),
28       get: function() {
29         if (this.getDataValue('production')) {
30                                         return _.toString(this.getDataValue('production'));
31                                 }
32       }
33     }
34   }, {
35     tableName: 'square_projects'
36   });
37
38   return SquareProject;
39
40 };