mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-18 03:28:45 +00:00
change how tags are checked
This commit is contained in:
+15
-13
@@ -29,25 +29,27 @@ const rendererConditions = (legacy, v3)=>{
|
|||||||
return {}; // If all renderers selected, renderer field not needed in query for speed
|
return {}; // If all renderers selected, renderer field not needed in query for speed
|
||||||
};
|
};
|
||||||
|
|
||||||
const tagConditions = (tagsAnd, tagsOr, tagsNot)=>{
|
const tagConditions = (tagsAnd, tagsOr, tagsNot) => {
|
||||||
const conditions = {};
|
const conditions = {};
|
||||||
|
|
||||||
if(tagsAnd.length > 0) {
|
if (tagsAnd.length > 0) {
|
||||||
conditions.$and = tagsAnd.map((tag)=>({
|
conditions.tags = {
|
||||||
tags : tag.trim()
|
$all: tagsAnd.map(tag => tag.trim())
|
||||||
}));
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tagsOr.length > 0) {
|
if (tagsOr.length > 0) {
|
||||||
conditions.$or = tagsOr.map((tag)=>({
|
conditions.tags = {
|
||||||
tags : tag.trim()
|
...conditions.tags,
|
||||||
}));
|
$in: tagsOr.map(tag => tag.trim())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tagsNot.length > 0) {
|
if (tagsNot.length > 0) {
|
||||||
conditions.$nor = tagsNot.map((tag)=>({
|
conditions.tags = {
|
||||||
tags : tag.trim()
|
...conditions.tags,
|
||||||
}));
|
$nin: tagsNot.map(tag => tag.trim())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return conditions;
|
return conditions;
|
||||||
|
|||||||
Reference in New Issue
Block a user