import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() async function main() { const userId = "dev-user-id" // we will grab the first user const user = await prisma.user.findFirst() if (!user) { console.log("No user found") return } console.log(`Testing for user: ${user.email} (${user.id})`) const rows = await prisma.$queryRawUnsafe>( `SELECT ne."noteId", ne."embedding"::text AS "embedding" FROM "NoteEmbedding" ne INNER JOIN "Note" n ON n.id = ne."noteId" WHERE n."userId" = $1 AND n."trashedAt" IS NULL AND ne."embedding" IS NOT NULL`, user.id ) console.log(`Fetched ${rows.length} embedding rows`) let success = 0 let fail = 0 rows.forEach((row, i) => { try { const parsed = JSON.parse(row.embedding) if (Array.isArray(parsed)) { success++ if (i === 0) { console.log(`Example vector size: ${parsed.length}, First few values: ${parsed.slice(0, 5)}`) } } else { fail++ } } catch (e) { fail++ if (fail === 1) { console.error("Failed example text:", row.embedding.slice(0, 100)) console.error(e) } } }) console.log(`Parsing results: Success=${success}, Fail=${fail}`) } main().catch(console.error).finally(() => prisma.$disconnect())