Files
setrip/server/repositories/profile.repo.ts
T

38 lines
863 B
TypeScript

import { prisma } from "@/lib/prisma";
import type { Vibe } from "@/app/generated/prisma/enums";
interface UpsertProfileInput {
bio?: string;
city?: string;
instagram?: string;
interests: string[];
vibe?: Vibe;
}
export const profileRepo = {
async findByUserId(userId: string) {
return prisma.userProfile.findUnique({ where: { userId } });
},
async upsertByUserId(userId: string, data: UpsertProfileInput) {
return prisma.userProfile.upsert({
where: { userId },
create: {
userId,
bio: data.bio,
city: data.city,
instagram: data.instagram,
interests: data.interests,
vibe: data.vibe,
},
update: {
bio: data.bio,
city: data.city,
instagram: data.instagram,
interests: data.interests,
vibe: data.vibe,
},
});
},
};