Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/wrangler-3.60.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jharrell authored Jun 17, 2024
2 parents ab9970e + ae57130 commit bff4171
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,11 @@ const getActiveUsers = await prisma.user.findMany({

> **Note**: It is not currently possible to [return the count of a relation](https://github.com/prisma/prisma/issues/5079).
### Sort by relevance (PostgreSQL)
### Sort by relevance (PostgreSQL and MySQL)

In [3.5.0](https://github.com/prisma/prisma/releases/3.5.0) and later, when using PostgreSQL you can sort records by relevance to the query using the `_relevance` keyword. This uses the relevance ranking functions from PostgreSQL's full text search feature, which are explained further in [the PostgreSQL documentation](https://www.postgresql.org/docs/12/textsearch-controls.html).
In [3.5.0+](https://github.com/prisma/prisma/releases/3.5.0) for PostgreSQL and [3.8.0+](https://github.com/prisma/prisma/releases/3.8.0) for MySQL, you can sort records by relevance to the query using the `_relevance` keyword. This uses the relevance ranking functions from full text search features.

This feature is further explain in [the PostgreSQL documentation](https://www.postgresql.org/docs/12/textsearch-controls.html) and [the MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html).

Enable order by relevance with the `fullTextSearch` [preview feature](/orm/prisma-client/queries/full-text-search):

Expand All @@ -416,6 +418,13 @@ const getUsersByRelevance = await prisma.user.findMany({
})
```

:::info

Enabling the `fullTextSearch` preview feature breaks the imports of the `<Model>OrderByWithRelationInput` TypeScript types. It is is renamed to `<Model>OrderByWithRelationAndSearchRelevanceInput`.

:::


### Sort with null records first or last

<Admonition type="info">
Expand Down
80 changes: 16 additions & 64 deletions content/400-pulse/400-api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ You can pass an object with configuration options to `stream()`. The object has

When called with no filter arguments, the `stream()` method returns the following type:

<TabbedContent code>
<TabItem value="Type">

```ts
PulseSubscription<
```ts no-copy
const stream: PulseSubscription<
| PulseCreateEvent<{
id: number;
name: string | null;
Expand All @@ -73,44 +70,23 @@ PulseSubscription<
name: string | null;
email: string;
}>
>;
> = await prisma.user.stream();
```

</TabItem>
<TabItem value="No filter arguments">
```ts
const stream = await prisma.user.stream()
```

</TabItem>
</TabbedContent>

Depending on the arguments you provide, the return type may change. For example, if you filter for only `create` events, the type will get adjusted:

<TabbedContent code>
<TabItem value="Type">

```ts
PulseSubscription<
```ts no-copy
const stream: PulseSubscription<
PulseCreateEvent<{
id: number;
email: string;
name: string | null;
}>
>;
```

</TabItem>
<TabItem value="Filter for `create` events">
```ts
const stream = await prisma.user.stream({
create: {}
})
> = await prisma.user.stream({
create: {},
});
```

</TabItem>
</TabbedContent>

### Examples

#### Use a `name` to be able to "resume" the stream
Expand Down Expand Up @@ -190,11 +166,8 @@ You can pass an object with configuration options to `subscribe()`. The object h

When called with no filter arguments, the `subscribe()` method returns the following type:

<TabbedContent code>
<TabItem value="Type">

```ts
PulseSubscription<
```ts no-copy
const subscription: PulseSubscription<
| PulseCreateEvent<{
id: number;
name: string | null;
Expand All @@ -210,44 +183,23 @@ PulseSubscription<
name: string | null;
email: string;
}>
>;
> = await prisma.user.subscribe();
```

</TabItem>
<TabItem value="No filter arguments">
```ts
const subscription = await prisma.user.subscribe()
```

</TabItem>
</TabbedContent>

Depending on the arguments you provide, the return type may change. For example, if you filter for only `create` events, the type will get adjusted:

<TabbedContent code>
<TabItem value="Type">

```ts
PulseSubscription<
```ts no-copy
const subscription: PulseSubscription<
PulseCreateEvent<{
id: number;
email: string;
name: string | null;
}>
>;
```

</TabItem>
<TabItem value="Filter for `create` events">
```ts
const subscription = await prisma.user.subscribe({
create: {}
})
> = await prisma.user.subscribe({
create: {},
});
```

</TabItem>
</TabbedContent>

### Examples

#### Filter for new `User` records with a non-null value for `name`
Expand Down

0 comments on commit bff4171

Please sign in to comment.