@prisma/orm-mongo 8.0.0-rc.17-dev.30 → 8.0.0-rc.17-dev.32
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.17-dev.
|
|
3
|
+
"version": "8.0.0-rc.17-dev.32",
|
|
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.17-dev.
|
|
14
|
-
"@prisma/orm-framework": "8.0.0-rc.17-dev.
|
|
15
|
-
"@prisma/orm-target-mongo": "8.0.0-rc.17-dev.
|
|
16
|
-
"@prisma/orm-toolchain": "8.0.0-rc.17-dev.
|
|
13
|
+
"@prisma/orm-family-mongo": "8.0.0-rc.17-dev.32",
|
|
14
|
+
"@prisma/orm-framework": "8.0.0-rc.17-dev.32",
|
|
15
|
+
"@prisma/orm-target-mongo": "8.0.0-rc.17-dev.32",
|
|
16
|
+
"@prisma/orm-toolchain": "8.0.0-rc.17-dev.32",
|
|
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.17-dev.
|
|
23
|
-
"@repo/tsconfig": "8.0.0-rc.17-dev.
|
|
24
|
-
"@repo/tsdown": "8.0.0-rc.17-dev.
|
|
22
|
+
"@internal/mongo": "8.0.0-rc.17-dev.32",
|
|
23
|
+
"@repo/tsconfig": "8.0.0-rc.17-dev.32",
|
|
24
|
+
"@repo/tsdown": "8.0.0-rc.17-dev.32",
|
|
25
25
|
"tsdown": "0.22.14",
|
|
26
26
|
"typescript": "5.9.3"
|
|
27
27
|
},
|
package/skills/prisma-8/SKILL.md
CHANGED
|
@@ -260,6 +260,8 @@ model Feature {
|
|
|
260
260
|
}
|
|
261
261
|
```
|
|
262
262
|
|
|
263
|
+
A variant's base can be in another namespace: write `@@base(ns.Model, "value")`. Such a variant must set `@@map(...)`, because a variant that shares its base's table has to be in the base's namespace.
|
|
264
|
+
|
|
263
265
|
Verify the polymorphism syntax against the interpreter tests if in doubt: `packages/2-sql/2-authoring/contract-psl/test/interpreter.polymorphism.test.ts`.
|
|
264
266
|
|
|
265
267
|
Mongo PSL takes the same `@@discriminator(field)` / `@@base(Base, "value")` attributes (the Mongo interpreter implements both; `examples/mongo-demo/src/contract.prisma` declares `Post` with `@@discriminator(kind)` and `Article` / `Tutorial` variants via `@@base(Post, "article")`). Variants share the base's collection — there is no `@@map` on a Mongo variant, since there is no second table to join. The TS builder's `discriminator` option on the model is the programmatic equivalent.
|
|
@@ -356,6 +358,46 @@ namespace public {
|
|
|
356
358
|
|
|
357
359
|
Canonical worked example: `examples/supabase/src/contract.prisma`.
|
|
358
360
|
|
|
361
|
+
## Workflow — Mixins (shared members)
|
|
362
|
+
|
|
363
|
+
The concept: a mixin is a named set of members for one kind of block. Declare it with the block's keyword followed by `mixin`, and include it in a block with `+<Name>`. The emitted contract is the same as if the mixin's members were written at the position of the inclusion.
|
|
364
|
+
|
|
365
|
+
```prisma
|
|
366
|
+
model mixin Timestamps {
|
|
367
|
+
createdAt DateTime @default(now())
|
|
368
|
+
updatedAt DateTime @default(now())
|
|
369
|
+
@@index([createdAt])
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
enum mixin BaseRoles {
|
|
373
|
+
ADMIN = "admin"
|
|
374
|
+
USER = "user"
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
model User {
|
|
378
|
+
id Int @id
|
|
379
|
+
+Timestamps
|
|
380
|
+
email String
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
enum Role {
|
|
384
|
+
@@type("pg/text@1")
|
|
385
|
+
+BaseRoles
|
|
386
|
+
GUEST = "guest"
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
`User` has the fields `id`, `createdAt`, `updatedAt`, `email`, in that order, and the index on `createdAt`. `Role` has the members `ADMIN`, `USER`, `GUEST`.
|
|
391
|
+
|
|
392
|
+
Rules:
|
|
393
|
+
|
|
394
|
+
- **One keyword per mixin.** A `model mixin` can be included only in models, a `type mixin` only in composite types, an `enum mixin` only in enums, and a mixin for a block an extension defines (for example `policy_select mixin`) only in blocks of that keyword.
|
|
395
|
+
- **A member provided twice is an error.** A field name or an enum member that the block already has, from its own body or from another mixin, is reported and the earlier one is kept. Including the same mixin twice in one block is also an error.
|
|
396
|
+
- **A mixin's attributes can name only its own fields.** `@@index([createdAt])` inside `Timestamps` works because `createdAt` is a field of the mixin. An attribute that needs a field of the including model belongs in that model; a model's own attributes can name the fields a mixin provides, as in `@@id([tenantId, id])`.
|
|
397
|
+
- **A mixin cannot include a mixin.**
|
|
398
|
+
- **Names follow namespaces.** A mixin declared in `namespace auth { ... }` is included from another namespace as `+auth.Timestamps`. The types of its fields are looked up from the mixin's namespace, not from the including block's.
|
|
399
|
+
- **A mixin is not a type.** It cannot be used as a field type, and it produces nothing in the contract unless a block includes it.
|
|
400
|
+
|
|
359
401
|
## Workflow — Cross-contract foreign keys
|
|
360
402
|
|
|
361
403
|
The concept: a relation field can reference a model in another contract space using the `<space>:<namespace>.<Model>` form. The contract also supports top-level named-type aliases in a `types {}` block, backed by the same bare type-position constructors used by fields. The `@db.X(args)` channel is removed: rewrite `@db.X` as `X` and `@db.X(args)` as `X(args)`; remaining uses fail with an actionable diagnostic naming the replacement.
|