const whereClause = {
AND: tagsToSearch?.map((tag) => ({
tags: {
some: {
name: {
contains: tag,
},
},
},
})),
};
const posts = await db.post.findMany({
orderBy: {
createdAt: sortBy,
},
include: {
user: {
select: {
name: true,
},
},
tags: true,
},
where: whereClause,
});
const whereClause = {
AND: tagsToSearch?.map((tag) => ({
tags: {
some: {
name: {
contains: tag,
},
},
},
})),
};
const posts = await db.post.findMany({
orderBy: {
createdAt: sortBy,
},
include: {
user: {
select: {
name: true,
},
},
tags: true,
},
where: whereClause,
});