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

try to speak mangoose

parent e333ecc6
No related branches found
No related tags found
1 merge request!4Url/year/title
...@@ -18,13 +18,9 @@ const urltoucans = Toucan.aggregate([ ...@@ -18,13 +18,9 @@ const urltoucans = Toucan.aggregate([
{$reduce: {$reduce:
{input: "$titlelc",initialValue: "", {input: "$titlelc",initialValue: "",
in: { $concat : ["$$value", "$$this"]}}} }}, in: { $concat : ["$$value", "$$this"]}}} }},
{$addFields:
{urlIdstring:
{$concat:["$titlelcnospace","-","$year"]}}},
{$addFields: {$addFields:
{urlId: {urlId:
{$toObjectId :"$urlIdstring"} {$concat:["$titlelcnospace","-","$year"]}}},
}},
{$unset:["titlelc","year","titlelcnospace","title","date"]}, {$unset:["titlelc","year","titlelcnospace","title","date"]},
]); ]);
...@@ -162,7 +158,7 @@ router.route("/img/:id") ...@@ -162,7 +158,7 @@ router.route("/img/:id")
try { try {
console.log(req.params.url); console.log(req.params.url);
urltoucans. urltoucans.
match({urlID: mongoose.Types.ObjectId('boule-2022')}). match({_id: mongoose.Types.ObjectId('5fc9e888f47f0041d8b83719')}).
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