MongoDB deleteAll() tells users to call where() even after where({})

Open
#30,784 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #30785 by @lazerg — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
mongodb, node.js, typescript

Research direction

Start with the MongoDB ORM's .where({}) handling and the .deleteAll() guard that emits the misleading error; the issue provides the reproduction but no file or test paths. Read that guard and its related tests first. Done means an empty filter produces accurate guidance on the supported explicit delete-all path, with regression coverage. An open linked pull request already addresses this issue.

Written by the indexing model from the issue text.

Description

Package and version

@prisma/[email protected], [email protected]

What happened?

While clearing a collection before reseeding, .where({}).deleteAll() throws an error instructing me to call .where(), which I already did.

If an empty filter is intentionally blocked for safety, the message does not explain that or tell me how to explicitly clear the collection.

What did you expect to happen?

Explain that an empty filter is rejected and show the supported way to explicitly delete everything, rather than instructing me to call .where() again.

Minimal reproduction

With a configured transactions collection, run:

await db.orm.transactions.where({}).deleteAll(); // Throws despite calling .where():
// deleteAll() requires a .where() filter. Call .where() before .deleteAll()

No dataset is required: the guard throws before a database command is sent.

Environment
  • Node.js: 24.9.0
  • OS: macOS, Darwin 24.6.0
  • Package manager: npm 11.6.0
  • Database: MongoDB 8.2.0-rc4, local single-node replica set
  • Scaffold: [email protected]
Additional context

The workaround used was the MongoDB driver's collection.deleteMany({}).

In current source, .where({}) adds no filter expressions, so .deleteAll() treats it like a missing .where() call.

The separate db.query builder exposes .from('transactions').deleteAll(), but the ORM error does not direct users to it.

The current source was checked; the reproduction was not rerun during drafting.

Dominant language
TypeScript
Stars
47.8k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
227

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prisma/orm

All issues in prisma/orm

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.