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

try to speak mangoose

parent 06946b32
Branches
No related tags found
1 merge request!4Url/year/title
...@@ -19,8 +19,12 @@ const urltoucans = Toucan.aggregate([ ...@@ -19,8 +19,12 @@ const urltoucans = Toucan.aggregate([
{input: "$titlelc",initialValue: "", {input: "$titlelc",initialValue: "",
in: { $concat : ["$$value", "$$this"]}}} }}, in: { $concat : ["$$value", "$$this"]}}} }},
{$addFields: {$addFields:
{urlId: {urlIdstring:
{$concat:["$titlelcnospace","-","$year"]}}}, {$concat:["$titlelcnospace","-","$year"]}}},
{$addFields:
{urlId:
{$toObjectId :"$urlIdstring"}
}},
{$unset:["titlelc","year","titlelcnospace","title","date"]}, {$unset:["titlelc","year","titlelcnospace","title","date"]},
]); ]);
...@@ -158,7 +162,7 @@ router.route("/img/:id") ...@@ -158,7 +162,7 @@ router.route("/img/:id")
try { try {
console.log(req.params.url); console.log(req.params.url);
urltoucans. urltoucans.
match({urlID: mongoose.Types.String('boule-2022')}). match({urlID: mongoose.Types.ObjectId('boule-2022')}).
exec((err,data) => { exec((err,data) => {
if (err) { if (err) {
console.log(err); console.log(err);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment