Ajout initial des fichiers du projet

This commit is contained in:
Rampeur
2025-08-08 10:47:29 +02:00
parent 29635cdf83
commit ffdc93834a
46 changed files with 15499 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
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);