major bug fixed + error handling

This commit is contained in:
Daniel
2023-06-27 03:05:12 +03:30
parent f1bd48be83
commit 92f6ee3942
10 changed files with 122 additions and 86 deletions
+35 -29
View File
@@ -103,39 +103,43 @@ export default async function getLink(userId: number, body: string) {
query.searchQuery && !query.searchFilter?.tags
? undefined
: {
some: {
id: query.tagId ? query.tagId : undefined, // If tagId was defined, filter by tag
name:
query.searchQuery && query.searchFilter?.tags
? {
contains: query.searchQuery,
mode: "insensitive",
}
: undefined,
OR: [
{ ownerId: userId }, // Tags owned by the user
{
links: {
some: {
name: {
contains:
query.searchQuery && query.searchFilter?.tags
? query.searchQuery
: undefined,
mode: "insensitive",
},
collection: {
members: {
some: {
userId, // Tags from collections where the user is a member
some: query.tagId
? {
// If tagId was defined, filter by tag
id: query.tagId,
name:
query.searchQuery && query.searchFilter?.tags
? {
contains: query.searchQuery,
mode: "insensitive",
}
: undefined,
OR: [
{ ownerId: userId }, // Tags owned by the user
{
links: {
some: {
name: {
contains:
query.searchQuery &&
query.searchFilter?.tags
? query.searchQuery
: undefined,
mode: "insensitive",
},
collection: {
members: {
some: {
userId, // Tags from collections where the user is a member
},
},
},
},
},
},
},
},
],
},
],
}
: undefined,
},
},
],
@@ -153,5 +157,7 @@ export default async function getLink(userId: number, body: string) {
},
});
console.log(links);
return { response: links, status: 200 };
}