108 lines
2.5 KiB
JavaScript
108 lines
2.5 KiB
JavaScript
var mongoose = require('mongoose');
|
|
|
|
var X2DataLogSchema = new mongoose.Schema({
|
|
id: String,
|
|
name: String,
|
|
type: String,
|
|
description: String,
|
|
landingZone: String,
|
|
speed: {
|
|
freeFall: {
|
|
vertical: {
|
|
max: Number,
|
|
avg: Number
|
|
},
|
|
horizontal: {
|
|
max: Number,
|
|
avg: Number
|
|
}
|
|
},
|
|
underCanopy: {
|
|
vertical: {
|
|
max: Number,
|
|
avg: Number
|
|
},
|
|
horizontal: {
|
|
max: Number,
|
|
avg: Number
|
|
}
|
|
}
|
|
},
|
|
glideRatio: {
|
|
freeFall: {
|
|
max: Number,
|
|
avg: Number
|
|
},
|
|
underCanopy: {
|
|
max: Number,
|
|
avg: Number
|
|
}
|
|
},
|
|
duration: {
|
|
freeFall: Number,
|
|
underCanopy: Number
|
|
},
|
|
distance: {
|
|
exitFromLandingZone: Number,
|
|
totalFlying: Number,
|
|
totalHorizontal: Number
|
|
},
|
|
altitude: {
|
|
exit: Number,
|
|
deployment: Number
|
|
},
|
|
cutaway: String,
|
|
malfunctions: [
|
|
{
|
|
name: String,
|
|
type: String
|
|
}
|
|
],
|
|
date: String,
|
|
createdOn: String,
|
|
author: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }
|
|
}, {timestamps: true, toJSON: {virtuals: true}});
|
|
|
|
X2DataLogSchema.methods.toJSONFor = function() {
|
|
return {
|
|
id: this.id,
|
|
name: this.name,
|
|
type: this.type,
|
|
description: this.description,
|
|
landingZone: this.landingZone,
|
|
speed: this.speed,
|
|
glideRatio: this.glideRatio,
|
|
duration: this.duration,
|
|
distance: this.distance,
|
|
altitude: this.altitude,
|
|
cutaway: this.cutaway,
|
|
malfunctions: this.malfunctions,
|
|
date: this.date,
|
|
createdOn: this.createdOn
|
|
};
|
|
};
|
|
|
|
X2DataLogSchema.methods.toJSONForUser = function(user) {
|
|
return {
|
|
id: this.id,
|
|
name: this.name,
|
|
type: this.type,
|
|
description: this.description,
|
|
landingZone: this.landingZone,
|
|
speed: this.speed,
|
|
glideRatio: this.glideRatio,
|
|
duration: this.duration,
|
|
distance: this.distance,
|
|
altitude: this.altitude,
|
|
cutaway: this.cutaway,
|
|
malfunctions: this.malfunctions,
|
|
date: this.date,
|
|
createdOn: this.createdOn,
|
|
createdAt: this.createdAt,
|
|
updatedAt: this.updatedAt,
|
|
author: this.author.toProfileJSONFor(user)
|
|
};
|
|
};
|
|
|
|
mongoose.model('X2DataLog', X2DataLogSchema);
|