Skip to content
Snippets Groups Projects
Commit 3fb33f03 authored by Inès Yeterian's avatar Inès Yeterian
Browse files

insh ça casse pas, ajout d'un champ toucan_id = titreAnnee

parent f52de6b4
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,9 @@ var Schema = mongoose.Schema;
* Indique ce que l'on doit trouver dans un toucan
*/
var toucanSchema = new Schema ({
toucan_id: {type: String, required: true},
title: {type : String, required: true}, // Chaque toucan doit avoir un titre et une date
date: {type : Date, required: true},
date: {type : Date, required: true}
});
// La date doit être unique
......
......@@ -58,6 +58,7 @@ router.route("/toucans")
}
});
}
toucan.toucan_id = toucan.title.replace(/\s+/g, '-').toLowerCase()+ toucan.date.getYear().toString();
toucan.save(function(err) {
if (err) {
res.status(400).send(err);
......@@ -131,7 +132,7 @@ router.route("/pdf/:title")
res.end(500);
return;
} else if (!data) {
res.status(404).send("Toucan non trouvée");
res.status(404).send("Toucan non trouvé");
return;
}
const id = data._id;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment