mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 21:27:20 +01:00
Updated user get.
This commit is contained in:
parent
ea28511b3c
commit
02c9e0115e
2 changed files with 12 additions and 8 deletions
|
|
@ -11,13 +11,17 @@ export interface GetUserOptions {
|
|||
}
|
||||
|
||||
async function getUser(
|
||||
where: Prisma.UserWhereInput | Prisma.UserWhereUniqueInput,
|
||||
where: Prisma.UserWhereUniqueInput,
|
||||
options: GetUserOptions = {},
|
||||
): Promise<User> {
|
||||
const { includePassword = false, showDeleted = false } = options;
|
||||
|
||||
return prisma.client.user.findFirst({
|
||||
where: { ...where, ...(showDeleted ? {} : { deletedAt: null }) },
|
||||
if (showDeleted) {
|
||||
where.deletedAt = null;
|
||||
}
|
||||
|
||||
return prisma.client.user.findUnique({
|
||||
where,
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
|
|
@ -28,8 +32,8 @@ async function getUser(
|
|||
});
|
||||
}
|
||||
|
||||
export async function getUserById(userId: string, options: GetUserOptions = {}) {
|
||||
return getUser({ id: userId }, options);
|
||||
export async function getUserById(id: string, options: GetUserOptions = {}) {
|
||||
return getUser({ id }, options);
|
||||
}
|
||||
|
||||
export async function getUserByUsername(username: string, options: GetUserOptions = {}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue