This commit is contained in:
Daniel
2023-07-05 10:43:37 +03:30
parent 9af7bab1db
commit 818b04b781
3 changed files with 15 additions and 38 deletions
+15 -26
View File
@@ -41,6 +41,21 @@ export default async function getLink(userId: number, body: string) {
}
: undefined,
where: {
collection: {
id: query.collectionId ? query.collectionId : undefined, // If collectionId was defined, filter by collection
OR: [
{
ownerId: userId,
},
{
members: {
some: {
userId,
},
},
},
],
},
[query.searchQuery ? "OR" : "AND"]: [
{
pinnedBy: query.pinnedOnly ? { some: { id: userId } } : undefined,
@@ -72,32 +87,6 @@ export default async function getLink(userId: number, body: string) {
mode: "insensitive",
},
},
{
collection: {
id: query.collectionId ? query.collectionId : undefined, // If collectionId was defined, filter by collection
name:
query.searchQuery && query.searchFilter?.collection
? {
contains: query.searchQuery,
mode: "insensitive",
}
: undefined,
OR: query.searchQuery
? undefined
: [
{
ownerId: userId,
},
{
members: {
some: {
userId,
},
},
},
],
},
},
{
tags:
query.searchQuery && !query.searchFilter?.tags