Skip to content

Instantly share code, notes, and snippets.

@robwormald
Last active January 3, 2016 19:59
Show Gist options
  • Save robwormald/8512466 to your computer and use it in GitHub Desktop.
Save robwormald/8512466 to your computer and use it in GitHub Desktop.
/**
* Employee
*
* @module :: Model
* @description :: A short summary of how this model works and what it represents.
* @docs :: http://sailsjs.org/#!documentation/models
*/
var uuid = require('node-uuid')
module.exports = {
connections : ['mcguffy_mccloud2'],
attributes: {
id : {
type : 'string',
primaryKey : true,
required : true,
},
// domain : {
// model : 'domain'
// },
employeeNumber : {
type: 'string',
},
employeeName : {
type : 'string',
},
email : {
type : 'string',
},
title : {
type : 'string',
},
firstName : {
type : 'string',
columnName : 'name_first'
},
middleName : {
type : 'string',
},
lastName : {
type : 'string',
columnName : 'name_last'
},
suffix : {
type : 'string',
},
gender : {
type : 'string',
},
hireDate : {
type : 'date'
},
birthday : {
type : 'date'
},
timelogs : {
collection : 'timelog'
},
toJSON : function(){
var obj = this.toObject();
obj.displayName = obj.firstName + ' ' + obj.lastName;
return obj;
}
/* e.g.
nickname: 'string'
*/
},
beforeCreate : function(values,cb){
if(!values.id){
values.id = uuid.v4();
}
cb()
}
};
/**
* OperationCode
*
* @module :: Model
* @description :: A short summary of how this model works and what it represents.
* @docs :: http://sailsjs.org/#!documentation/models
*/
var uuid = require('node-uuid')
module.exports = {
connections : ['mcguffy_mccloud2'],
//tableName : 'time_log_dev',
attributes: {
id : {
type : 'uuid',
primaryKey : true,
required : true,
},
operation_code : {
type : 'string'
},
//start : {},
// domain : {
// model : 'domain'
// },
beforeCreate : function(values,cb){
if(!values.id){
values.id = uuid.v4();
}
cb()
}
}
}
/**
* Project
*
* @module :: Model
* @description :: A short summary of how this model works and what it represents.
* @docs :: http://sailsjs.org/#!documentation/models
*/
var uuid = require('node-uuid')
module.exports = {
connections : ['mcguffy_mccloud2'],
attributes: {
id : {
type : 'string',
primaryKey : true,
required : true,
},
projectTitle : {
type : 'string',
columnName : 'project_title'
//unique : 'true'
},
projectNumber : {
type : 'string',
columnName : 'project_number'
},
toJSON : function(){
var obj = this.toObject()
obj.displayName = obj.projectNumber + ' : ' + obj.projectTitle
return obj;
}
/* e.g.
nickname: 'string'
*/
},
beforeCreate : function(values,cb){
if(!values.id){
values.id = uuid.v4();
}
cb()
}
};
/**
* TimeActivity
*
* @module :: Model
* @description :: A short summary of how this model works and what it represents.
* @docs :: http://sailsjs.org/#!documentation/models
*/
var uuid = require('node-uuid')
module.exports = {
connections : ['mcguffy_mccloud2'],
//autoPK : false,
attributes: {
id : {
type : 'string',
primaryKey : true,
required : true,
},
user : {
model : 'user',
required : true
},
employee : {
model : 'employee'
},
customer : {
model : 'customer',
},
item : {
model : 'item',
},
job : {
model : 'job',
},
start : {
type : 'dateTime',
},
end : {
type : 'dateTime',
},
// domain : {
// model : 'domain'
// },
duration_minutes : {
type : 'integer'
},
approvalStatus : {
type : 'string'
}
/* e.g.
nickname: 'string'
*/
},
beforeCreate : function(values,cb){
if(!values.id){
values.id = uuid.v4();
}
cb()
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment