Update: Ad.update remove duplicate interests + Ad.findAll can filter with multiple interest with ','

This commit is contained in:
Yûki VACHOT 2021-12-13 23:07:16 +01:00
parent 8f39312a6e
commit 73831f0dd0

View file

@ -70,7 +70,7 @@ exports.findAll = (req, res) => {
query.url = condition;
const interests = req.query.interests;
condition = interests ? {$in: interests} : undefined;
condition = interests ? {$in: interests.split(',')} : undefined;
query["interests.interest"] = condition
const comment = req.query.comment;
@ -174,9 +174,9 @@ exports.update = (req, res) => {
condition = url ? url : undefined;
update.url = condition;
const interests = req.body.interests;
condition = interests ? interests : undefined;
update.interests = condition;
let interests = req.body.interests;
condition = interests ? {interests: [...new Map(interests.map(v => [v.id, v])).values()]} : undefined;
update.$addToSet = condition;
const comment = req.body.comment;
condition = comment ? comment : undefined;