mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
Updated search queries.
This commit is contained in:
parent
80a58cbdd1
commit
e971f2533d
12 changed files with 90 additions and 147 deletions
|
|
@ -24,41 +24,12 @@ export async function getTeams(
|
|||
criteria: TeamFindManyArgs,
|
||||
filters: TeamSearchFilter = {},
|
||||
): Promise<FilterResult<Team[]>> {
|
||||
const mode = prisma.getQueryMode();
|
||||
const { userId, query } = filters;
|
||||
const { getSearchParameters } = prisma;
|
||||
const { query } = filters;
|
||||
|
||||
const where: Prisma.TeamWhereInput = {
|
||||
...criteria.where,
|
||||
...(userId && {
|
||||
teamUser: {
|
||||
some: { userId },
|
||||
},
|
||||
}),
|
||||
...(query && {
|
||||
AND: {
|
||||
OR: [
|
||||
{
|
||||
name: {
|
||||
startsWith: query,
|
||||
mode,
|
||||
},
|
||||
},
|
||||
{
|
||||
teamUser: {
|
||||
some: {
|
||||
role: ROLES.teamOwner,
|
||||
user: {
|
||||
username: {
|
||||
startsWith: query,
|
||||
mode,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
...getSearchParameters(query, [{ name: 'contains' }]),
|
||||
};
|
||||
|
||||
return prisma.pagedQuery<TeamFindManyArgs>(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue