Initial Commit

This commit is contained in:
root
2013-05-06 03:38:29 -04:00
commit d392a540e7
134 changed files with 22012 additions and 0 deletions

25
app/model/client.js Normal file
View File

@ -0,0 +1,25 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;
var clientSchema = new Schema({
name: String,
identifier: String,
address: {
street1: String,
street2: String,
city: String,
state: String,
zip: String
},
contacts: [{
name: String,
phone: String,
email: String
}],
frequencies: {},
workorders: [{ type: ObjectId, ref: 'Workorder' }],
deleted: { type: Boolean, default: false }
});
module.exports = mongoose.model('Client', clientSchema);

12
app/model/counter.js Normal file
View File

@ -0,0 +1,12 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;
var counterSchema = new Schema({
name: String,
seq: { type: Number, default: 0 }
});
counterSchema.index({ field: 1, model: 1 }, { unique: true, required: true, index: -1 });
module.exports = mongoose.model('Counter', counterSchema);

24
app/model/user.js Normal file
View File

@ -0,0 +1,24 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;
var userSchema = new Schema({
name: {
first: String,
last: String
},
email: String,
picture: String,
refreshToken: String,
accessToken: String,
groups: [String],
perms: [String],
deleted: { type: Boolean, default: false }
});
userSchema.methods.hasPermission = function(perm) {
return this.perms.indexOf(perm) != -1;
}
var User = module.exports = mongoose.model('User', userSchema);

27
app/model/workorder.js Normal file
View File

@ -0,0 +1,27 @@
var mongoose = require('mongoose')
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;
var workorderSchema = new Schema({
biomedId: Number,
client: { type: ObjectId, ref: 'Client' },
createdOn: Date,
createdBy: { type: ObjectId, ref: 'User' },
reason: String,
remarks: String,
status: String,
scheduling: {
start: Date,
end: Date
},
calendarId: String,
techs: [{ type: ObjectId, ref: 'User' }],
history: [{
oldValues: {},
newValues: {},
modifiedBy: { type: ObjectId, ref: 'User' }
}],
deleted: { type: Boolean, default: false }
});
module.exports = mongoose.model('Workorder', workorderSchema);