@prisma/orm-mongo 8.0.0-rc.18-dev.4 → 8.0.0-rc.18-dev.6

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.18-dev.4",
3
+ "version": "8.0.0-rc.18-dev.6",
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.18-dev.4",
14
- "@prisma/orm-framework": "8.0.0-rc.18-dev.4",
15
- "@prisma/orm-target-mongo": "8.0.0-rc.18-dev.4",
16
- "@prisma/orm-toolchain": "8.0.0-rc.18-dev.4",
13
+ "@prisma/orm-family-mongo": "8.0.0-rc.18-dev.6",
14
+ "@prisma/orm-framework": "8.0.0-rc.18-dev.6",
15
+ "@prisma/orm-target-mongo": "8.0.0-rc.18-dev.6",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.18-dev.6",
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.18-dev.4",
23
- "@repo/tsconfig": "8.0.0-rc.18-dev.4",
24
- "@repo/tsdown": "8.0.0-rc.18-dev.4",
22
+ "@internal/mongo": "8.0.0-rc.18-dev.6",
23
+ "@repo/tsconfig": "8.0.0-rc.18-dev.6",
24
+ "@repo/tsdown": "8.0.0-rc.18-dev.6",
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.18-dev.4'
18
+ library_version: '8.0.0-rc.18-dev.6'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -123,7 +123,20 @@ model('Message', { fields: { id, text } }).sql(({ cols }) => ({
123
123
  @@fullTextIndex([[title, subtitle], body], name: "post_search")
124
124
  ```
125
125
 
126
- **Searching an index: name it.** Name the full-text index and pass it to `fns.fullTextMatches` and `fns.fullTextRank` in place of a column. The operation searches the document the index was built over, with the index's weight groups and language, so the query always matches the index, Postgres uses it, and a title match ranks above a body match. The index states its language, so passing `language` with one is a type error. An index of another type, or a name the model's table does not have, is a type error too.
126
+ **Searching an index in the ORM: `using`.** Every collection has a method under `using` for each full-text index of its model's table, named after the index. It filters to the matching rows and orders them by relevance, best first, and returns the same collection, so it chains like `where`:
127
+
128
+ ```typescript
129
+ const q = websearchToTsquery(query);
130
+ const posts = await db.orm.public.Post.select('id', 'title').using.post_search(q).limit(20).all();
131
+ const mine = await db.orm.public.Post.where({ userId }).using.post_search(q).all();
132
+ const users = await db.orm.public.User
133
+ .include('posts', (posts) => posts.using.post_search(q).limit(3))
134
+ .all();
135
+ ```
136
+
137
+ The relevance order is added where the method is called: an `orderBy` before it sorts first, one after it breaks ties. A custom collection class stays the class, so `this.using.post_search(q)` works in a class method. A model with no full-text index has no full-text methods, and a misspelled name is a type error. With the pgvector extension, `using` also has `<field>_nearest(vector, maxDistance?)` for each vector field, such as `db.orm.public.Post.using.embedding_nearest(v, 0.5)`: nearest by cosine distance first. `using` is reserved: a custom class cannot define its own `using`.
138
+
139
+ **Searching an index by hand: name it.** For anything `using` does not do, such as another order or `fullTextHeadline`, name the full-text index and pass it to `fns.fullTextMatches` and `fns.fullTextRank` in place of a column. The operation searches the document the index was built over, with the index's weight groups and language, so the query always matches the index, Postgres uses it, and a title match ranks above a body match. The index states its language, so passing `language` with one is a type error. An index of another type, or a name the model's table does not have, is a type error too.
127
140
 
128
141
  In the ORM, every `where` and `orderBy` callback receives a second argument `{ fns, indexes }`: `fns` is the SQL builder's functions, and `indexes` holds the indexes of the model's table under the name the contract gave each, `name:` or `map:`. A value from `fns`, such as a rank, has `.asc()` and `.desc()`:
129
142
 
@@ -176,6 +176,7 @@ The concept: the runtime runs every statement and every transaction as an **acti
176
176
 
177
177
  - Lifecycle events, for every activity: `activityStarted(activity, ctx)`, `activityEnded(activity, result, ctx)` and `activityFinalized(activity, result, ctx)`. Check `activity.kind` (`'statement'` or `'transaction'`) at the top. `activityEnded` fires when the act ends: for a statement with `result.outcome` (`'succeeded'`, `'failed'`, or `'stopped'` when the caller stopped reading), `result.latencyMs`, `result.source` (`'driver'`, or `'middleware'` for a cache hit) and `result.rowCount` or `result.stats` according to `result.returns`. `activityFinalized` fires once the effects are final, with `result.outcome` `'committed'`, `'rolled-back'` or `'unknown'`: right after the end outside a transaction, and when the transaction ends inside one. Every statement that started is finalized, even one blocked before it ran.
178
178
  - Interceptors, for statements: `beforeEncode(plan, ctx, params)` before parameters are encoded (throw to block the statement), `intercept.onQuery` / `intercept.onExecute` to supply a result instead of running it, and `onRow(row, plan, ctx)` for each driver row.
179
+ - Client activities: a client library can start an activity of its own kind, which contains a hyphen, such as `orm-call`, and send its statements beneath it. A middleware sees it through the same lifecycle events, with `activity.kind` set to that kind and `ctx.parent` of its statements pointing at it, and can supply its result through `intercept.onActivity(activity, ctx)`. Outside a transaction it is finalized right after it ends; inside one, when the transaction ends, after its statements. No built-in client starts one yet, so a middleware that handles only `'statement'` and `'transaction'` should ignore other kinds rather than fail on them.
179
180
 
180
181
  Every hook of one activity receives the same `ctx`. Keep per-statement state in `ctx.state(key)` (use a `Symbol()` key); `activity.id` identifies the activity, and `ctx.parent` is the enclosing transaction's context. There is no separate telemetry package — observe statements with `activityEnded`. The `SqlMiddleware` type comes from `@prisma/orm-postgres/family-runtime`. `examples/prisma-8-demo/src/prisma/slow-query-warning.ts` is the canonical example:
181
182