Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/prisma/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async function main() {

const runtime = await db.connect({ url })
try {
await clearUsers()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Cleanup scope is too broad and deletes non-demo users.

clearUsers() currently uses u.id.isNotNull(), which removes effectively all User rows. That makes reruns idempotent, but at the cost of wiping unrelated data in the same database. Restrict deletion to the seeded IDs (user-0..user-3) so the demo remains safely repeatable without destructive side effects.

Also applies to: 120-122

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/prisma/src/index.ts` at line 106, clearUsers() currently deletes all
users by checking u.id.isNotNull(); change it to only delete the demo seed users
by filtering on the specific seeded IDs (e.g. "user-0" through "user-3") so it
targets those IDs (use array membership or explicit ORs in the query) instead of
a non-null id check; update any other similar cleanup calls (the block around
the seed cleanup at the later location) to use the same seeded-ID filter to make
reruns idempotent without removing unrelated users.

await insertUsers()
await searchByEq()
await searchByIlikeAndDecrypt()
Expand All @@ -116,6 +117,13 @@ async function main() {
}
}

async function clearUsers(): Promise<void> {
const removed = await db.orm.User.where((u) => u.id.isNotNull()).deleteCount()
if (removed > 0) {
console.log(`--- Cleanup ---\nRemoved ${removed} existing user row(s).\n`)
}
}

async function insertUsers(): Promise<void> {
console.log('--- Insert (mixed-codec round-trip) ---')
await Promise.all(
Expand Down
Loading