@prisma/orm-mongo 8.0.0-rc.16-dev.2 → 8.0.0-rc.16-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-mongo",
3
- "version": "8.0.0-rc.16-dev.2",
3
+ "version": "8.0.0-rc.16-dev.4",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,18 +10,18 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-mongo": "8.0.0-rc.16-dev.2",
14
- "@prisma/orm-framework": "8.0.0-rc.16-dev.2",
15
- "@prisma/orm-target-mongo": "8.0.0-rc.16-dev.2",
16
- "@prisma/orm-toolchain": "8.0.0-rc.16-dev.2",
13
+ "@prisma/orm-family-mongo": "8.0.0-rc.16-dev.4",
14
+ "@prisma/orm-framework": "8.0.0-rc.16-dev.4",
15
+ "@prisma/orm-target-mongo": "8.0.0-rc.16-dev.4",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.16-dev.4",
17
17
  "mongodb-connection-string-url": "^7.0.1",
18
18
  "pathe": "^2.0.3",
19
19
  "tinyglobby": "^0.2.17"
20
20
  },
21
21
  "devDependencies": {
22
- "@internal/mongo": "8.0.0-rc.16-dev.2",
23
- "@repo/tsconfig": "8.0.0-rc.16-dev.2",
24
- "@repo/tsdown": "8.0.0-rc.16-dev.2",
22
+ "@internal/mongo": "8.0.0-rc.16-dev.4",
23
+ "@repo/tsconfig": "8.0.0-rc.16-dev.4",
24
+ "@repo/tsdown": "8.0.0-rc.16-dev.4",
25
25
  "tsdown": "0.22.14",
26
26
  "typescript": "5.9.3"
27
27
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-mongo'
18
- library_version: '8.0.0-rc.16-dev.2'
18
+ library_version: '8.0.0-rc.16-dev.4'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -84,7 +84,7 @@ The single source of truth: read the envelope, find the row by `code`, follow th
84
84
  | `CONTRACT.VALIDATION_FAILED` | `contract emit`, `db *` | Re-run `pnpm prisma contract emit` after fixing the contract source named in `where.path`; `meta.errors` lists the issues. See `references/contract.md`. |
85
85
  | `CONFIG.DB_CONNECTION_REQUIRED` | `db *`, `db migrate`, `migration status` | Pass `--db <url>` or set `db.connection` in `prisma.config.ts`. |
86
86
  | `CONFIG.MISSING_EXTENSION_PACKS` | `contract emit` (e.g. contract uses `pgvector.Vector(...)` but config does not list the pgvector descriptor) | Add the descriptors named in `meta.missingExtensionPacks` to `extensions` in `prisma.config.ts`. See `references/contract.md`. |
87
- | `MIGRATION.PLANNING_FAILED` | `db init`, `db update` | Inspect `meta.conflicts`. Recovery is per-conflict — chain to `references/migrations.md`. |
87
+ | `MIGRATION.PLANNING_FAILED` | `db init`, `db update`, `migration plan` | Inspect `meta.conflicts`. Recovery is per-conflict — chain to `references/migrations.md`. When `migration plan` raises it because the planner produced no operations, the conflict's `why` gives the next step (`migration new --from <hash>`, or `db sign` for a database managed with `db update`). |
88
88
  | `CLI.INIT_MISSING_FLAGS` / `CLI.INIT_INVALID_FLAG_VALUE` / `CLI.INIT_REINIT_NEEDS_FORCE` / `CLI.INIT_*` | `prisma orm init` | Re-run with the flags listed in `meta.missingFlags` or `meta.allowed`; a re-init needs `--confirm <directory name>`. `CLI.INIT_INSTALL_FAILED` (exit 4) and `CLI.INIT_EMIT_FAILED` (exit 5) are findings on a completed scaffold — the files are on disk; fix and re-run the named step. |
89
89
  | `MIGRATION.UNFILLED_PLACEHOLDER` | `node migrations/app/<dir>/migration.ts` (self-emit) or `db migrate` | Edit `migration.ts`, replace the `placeholder("<slot>")` named by `meta.slot` with a real query closure, self-emit. See `references/migrations.md`. |
90
90
  | `MIGRATION.FILE_MISSING` | Reading a migration package | Restore from version control or scaffold a fresh package with `migration plan` / `migration new`. |
@@ -574,6 +574,28 @@ await db.transaction(async (tx) => {
574
574
 
575
575
  The callback's return value passes through `db.transaction(...)`. Capture inserted ids out of the callback and use them downstream after commit.
576
576
 
577
+ To read a row and then write it without another transaction changing it in between, lock it when you read it. The lock lasts until the transaction ends; outside a transaction it is released when the statement ends.
578
+
579
+ ```typescript
580
+ await db.transaction(async (tx) => {
581
+ // ORM: locks only the model's own rows (`FOR UPDATE OF "product"`).
582
+ const product = await tx.orm.public.Product.where({ id }).forUpdate().first();
583
+
584
+ // SQL builder: the same lock on a plan.
585
+ const [row] = await tx.query(
586
+ tx.sql.public.product.select('id', 'stock').where((f, fns) => fns.eq(f.id, id)).forUpdate().build(),
587
+ );
588
+
589
+ // Work queue: claim the next unclaimed job, skipping jobs other workers hold.
590
+ const job = await tx.orm.public.Job.where({ state: 'queued' })
591
+ .orderBy((j) => j.createdAt.asc())
592
+ .forUpdate({ skipLocked: true })
593
+ .first();
594
+ });
595
+ ```
596
+
597
+ The four methods are `forUpdate()`, `forNoKeyUpdate()`, `forShare()` and `forKeyShare()`, each with `{ nowait: true }` or `{ skipLocked: true }`. On the ORM a lock cannot be combined with `include`, `groupBy`, `aggregate`, `distinct`, `distinctOn` or a mutation terminal (`ORM.LOCK_INCOMPATIBLE`).
598
+
577
599
  ## Namespace-aware accessors
578
600
 
579
601
  On Postgres both `db.sql` and `db.orm` are keyed by storage namespace (the Postgres schema) — always, not only when a contract declares more than one. A model outside any `namespace { }` block is in `public`:
@@ -607,6 +629,7 @@ Cross-namespace relations (e.g. `public.Profile` → `auth.User`) follow the sam
607
629
  10. **Mixing the ORM mutation return with `runtime.query(plan)` / `runtime.execute(plan)`.** ORM terminals issue the query themselves and return rows. The runtime methods are for SQL-builder plans.
608
630
  11. **Adding a `cursor()` to a relation, count, operation or `nulls` order.** It throws `ORM.ARGUMENT_INVALID`. Use `.limit(n).offset(n)`, or order by plain columns.
609
631
  12. **Ordering grouped rows by an aggregate metric.** The grouped collection supports `.orderBy(...)` on group keys plus `.limit(...)` / `.offset(...)`, but it cannot order by an aggregate alias such as `SUM(amount)`. Sorting the materialized aggregate result in JS is fine at small cardinalities; for large grouped result sets, drop to `db.sql.<ns>.<table>`.
632
+ 13. **Locking a parent row with `forUpdate()` while other transactions write rows that reference it.** Every insert or update of a row with a foreign key to the locked row takes `FOR KEY SHARE` on it to check the key, and `FOR KEY SHARE` conflicts with `FOR UPDATE`, so those writes wait and can deadlock. Use `forNoKeyUpdate()`: it still blocks writes to the row, but not the foreign-key check.
610
633
 
611
634
  ## Reference Files
612
635