@prisma/orm-mongo 8.0.0-rc.18-dev.3 → 8.0.0-rc.18-dev.5
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.
|
|
3
|
+
"version": "8.0.0-rc.18-dev.5",
|
|
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.
|
|
14
|
-
"@prisma/orm-framework": "8.0.0-rc.18-dev.
|
|
15
|
-
"@prisma/orm-target-mongo": "8.0.0-rc.18-dev.
|
|
16
|
-
"@prisma/orm-toolchain": "8.0.0-rc.18-dev.
|
|
13
|
+
"@prisma/orm-family-mongo": "8.0.0-rc.18-dev.5",
|
|
14
|
+
"@prisma/orm-framework": "8.0.0-rc.18-dev.5",
|
|
15
|
+
"@prisma/orm-target-mongo": "8.0.0-rc.18-dev.5",
|
|
16
|
+
"@prisma/orm-toolchain": "8.0.0-rc.18-dev.5",
|
|
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.
|
|
23
|
-
"@repo/tsconfig": "8.0.0-rc.18-dev.
|
|
24
|
-
"@repo/tsdown": "8.0.0-rc.18-dev.
|
|
22
|
+
"@internal/mongo": "8.0.0-rc.18-dev.5",
|
|
23
|
+
"@repo/tsconfig": "8.0.0-rc.18-dev.5",
|
|
24
|
+
"@repo/tsdown": "8.0.0-rc.18-dev.5",
|
|
25
25
|
"tsdown": "0.22.14",
|
|
26
26
|
"typescript": "5.9.3"
|
|
27
27
|
},
|
package/skills/prisma-8/SKILL.md
CHANGED
|
@@ -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
|
|
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
|
|