34 lines
740 B
TypeScript
34 lines
740 B
TypeScript
import { prisma } from "@/lib/prisma";
|
|
|
|
interface UpsertProfileInput {
|
|
bio?: string;
|
|
city?: string;
|
|
instagram?: string;
|
|
interests: string[];
|
|
}
|
|
|
|
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,
|
|
},
|
|
update: {
|
|
bio: data.bio,
|
|
city: data.city,
|
|
instagram: data.instagram,
|
|
interests: data.interests,
|
|
},
|
|
});
|
|
},
|
|
};
|