Change add,removeTag in CommentsService to use simpler query then elemMatch

This commit is contained in:
Benjamin Goering
2017-03-01 13:08:36 +08:00
parent 378622f7e8
commit 388c3182ea
+2 -2
View File
@@ -59,7 +59,7 @@ module.exports = class CommentsService {
const filter = {
id,
tags: {$not: {$elemMatch: {name}}}
'tags.name': {$ne: name},
};
const update = {
$push: {tags: {
@@ -101,7 +101,7 @@ module.exports = class CommentsService {
static removeTag(id, name) {
const filter = {
id,
tags: {$elemMatch: {name}}
'tags.name': name,
};
const update = {$pull: {tags: {name}}};
return CommentModel.update(filter, update)