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
+33
View File
@@ -0,0 +1,33 @@
var mongoose = require('mongoose');
var slug = require('slug');
var DropzoneSchema = new mongoose.Schema({
slug: { type: String, lowercase: true, unique: true },
lieu: String,
oaci: String,
author: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }
}, {timestamps: true, toJSON: {virtuals: true}});
DropzoneSchema.pre('validate', function (next) {
if (!this.slug) {
this.slugify();
}
next();
});
DropzoneSchema.methods.slugify = function () {
this.slug = slug(`${this.lieu} ${this.oaci}`) + '-' + (Math.random() * Math.pow(36, 6) | 0).toString(36);
};
DropzoneSchema.methods.toJSONFor = function(user){
return {
slug: this.slug,
lieu: this.lieu,
oaci: this.oaci,
createdAt: this.createdAt,
updatedAt: this.updatedAt,
author: this.author.toProfileJSONFor(user)
};
};
mongoose.model('Dropzone', DropzoneSchema);