Mongoose 6
Last reviewed Sep 20, 2026
Prompt Details
Prompt Composition
3prompts
- JavaScript ES2026102 lines · 3.1K tokens
- Node.js 22114 lines · 3.7K tokens
- Mongoose 670 lines · 3.4K tokens
Total286 lines · 10.3K tokens
CWE Coverage
- 15
- 20
- 22
- 59
- 78
- 79
- 89
- 95
- 113
- 117
- 201
- 208
- 209
- 214
- 250
- 295
- 297
- 319
- 323
- 327
- 338
- 346
- 347
- 352
- 354
- 362
- 367
- 377
- 426
- 444
- 459
- 471
- 488
- 494
- 502
- 522
- 532
- 602
- 639
- 653
- 732
- 770
- 772
- 807
- 829
- 838
- 862
- 863
- 908
- 915
- 916
- 918
- 922
- 942
- 943
- 1004
- 1321
- 1333
Prompt Preview
Apply the Node.js 22 prompt first. These rules target Mongoose 6 and were checked against 6.13.11 with its pinned MongoDB Node.js driver 4.17.2. Mongoose declares Node.js >= 12.0.0, but this tag's test matrix covers 12, 14, 16, and 18; validate the deployed Node.js 22 and MongoDB combination rather than treating that minimum as a compatibility guarantee.
Query filters and tenant boundaries
- Build filters from named, validated values; never pass request objects directly to
find(),findOne(),countDocuments(), updates, or deletes. Reject objects and arrays where a scalar is expected before Mongoose casting can interpret them as operators or an implicit$in. - Set
strictQuery: 'throw'on schemas used for scoped access. The Mongoose 6 default followsstrict, normallytrue, and silently strips unknown filter paths; a misspelled tenant field can otherwise widen a query. This setting does not reject an already empty filter or validate ownership. - Require a valid identifier and trusted tenant/owner scope before issuing an object operation; reject missing,
null, orundefinedscope values and never recover from a cast or strict-mode error by retrying with{}. Usetypeof id === 'string'andmongoose.isObjectIdOrHexString(id)for external ObjectId strings;isValidObjectId()also accepts numbers and 12-character strings. - Put tenant and any required soft-delete or ownership predicates in every relevant filter, including
distinct(),exists(), counts, and each bulk operation. UsecountDocuments(scopedFilter)for tenant counts;