WIP for Prisma integration and account and membership schema

This commit is contained in:
Michael Dausmann
2023-01-29 01:06:01 +11:00
parent 7246c0c5a4
commit 791192a1ae
6 changed files with 200 additions and 3 deletions

25
server/api/notes.ts Normal file
View File

@@ -0,0 +1,25 @@
import { PrismaClient } from '@prisma/client';
import { serverSupabaseClient } from '#supabase/server';
const prisma = new PrismaClient();
export default defineEventHandler(async (event) => {
const client = serverSupabaseClient(event)
const user = await client.auth.getUser();
const dbUser = await prisma.user.findFirstOrThrow({
where: {
supabase_uid: user.data.id // TODO - this shit is messy.. typing
},
include: {
membership: true, // Return all fields
},
});
const data = await prisma.note.findMany({
where:{
account_id: dbUser.membership?.account_id
}
});
return data;
})