basic tag search

This commit is contained in:
Víctor Losada Hernández
2026-10-28 17:33:54 +01:00
parent 017c386710
commit bab0656eab
2 changed files with 31 additions and 20 deletions
+11 -8
View File
@@ -29,12 +29,15 @@ const rendererConditions = (legacy, v3)=>{
return {}; // If all renderers selected, renderer field not needed in query for speed
};
const tagConditions = (tags) =>{
if(!tags) return {};
return {
$or: tags.map(tag => ({ tags: tag })),
}
}
const tagConditions = (tags) => {
if (!tags || tags.length === 0) return {};
return {
$or: tags.map(tag => ({
tags: tag.trim()
}))
};
};
const sortConditions = (sort, dir) => {
return {
@@ -48,7 +51,7 @@ const findBrews = async (req, res)=>{
const page = Math.max(parseInt(req.query.page) || 1, 1);
const count = Math.max(parseInt(req.query.count) || 20, 10);
const skip = (page - 1) * count;
const tags = req.query.tags || [];
const tags = req.query.tags.split(',') || [];
const sort = req.query.sort || 'title';
const dir = req.query.dir || 'asc';
@@ -94,7 +97,7 @@ const findBrews = async (req, res)=>{
const findTotal = async (req, res)=>{
const title = req.query.title || '';
const author = req.query.author || '';
const tags = req.query.tags || [];
const tags = req.query.tags.split(',') || [];
const combinedQuery = {
$and : [