mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Refactor filter handling for queries.
This commit is contained in:
parent
5b300f1ff5
commit
ee6c68d27c
107 changed files with 731 additions and 835 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { Prisma, User } from '@/generated/prisma/client';
|
||||
import { ROLES } from '@/lib/constants';
|
||||
import prisma from '@/lib/prisma';
|
||||
import { PageResult, Role, PageParams } from '@/lib/types';
|
||||
import { PageResult, Role, QueryFilters } from '@/lib/types';
|
||||
import { getRandomChars } from '@/lib/crypto';
|
||||
import UserFindManyArgs = Prisma.UserFindManyArgs;
|
||||
|
||||
|
|
@ -49,9 +49,9 @@ export async function getUserByUsername(username: string, options: GetUserOption
|
|||
|
||||
export async function getUsers(
|
||||
criteria: UserFindManyArgs,
|
||||
pageParams?: PageParams,
|
||||
filters: QueryFilters = {},
|
||||
): Promise<PageResult<User[]>> {
|
||||
const { search } = pageParams;
|
||||
const { search } = filters;
|
||||
|
||||
const where: Prisma.UserWhereInput = {
|
||||
...criteria.where,
|
||||
|
|
@ -68,7 +68,7 @@ export async function getUsers(
|
|||
{
|
||||
orderBy: 'createdAt',
|
||||
sortDescending: true,
|
||||
...pageParams,
|
||||
...filters,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue