Update: Ad.update remove duplicate interests + Ad.findAll can filter with multiple interest with ','
This commit is contained in:
parent
8f39312a6e
commit
73831f0dd0
1 changed files with 4 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Reference in a new issue