mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-11 05:05:07 -05:00
40 lines
839 B
TypeScript
40 lines
839 B
TypeScript
import type { Prisma } from "@prisma/client";
|
|
import { db } from "~/utils/db.server";
|
|
|
|
export type FindTrusters = Prisma.PromiseReturnType<typeof findTrusters>;
|
|
export function findTrusters(userId: string) {
|
|
return db.trustRelationships.findMany({
|
|
where: { trustReceiverId: userId },
|
|
select: {
|
|
trustGiver: {
|
|
select: {
|
|
id: true,
|
|
discordName: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export function findById(userId?: string) {
|
|
if (!userId) return;
|
|
return db.user.findUnique({ where: { id: userId } });
|
|
}
|
|
|
|
export function update({
|
|
userId,
|
|
miniBio,
|
|
weapons,
|
|
friendCode,
|
|
}: {
|
|
userId: string;
|
|
miniBio: Nullable<string>;
|
|
weapons: string[];
|
|
friendCode: Nullable<string>;
|
|
}) {
|
|
return db.user.update({
|
|
where: { id: userId },
|
|
data: { miniBio, weapons, friendCode },
|
|
});
|
|
}
|