Skip to content

Commit

Permalink
Add mdx comp to examples (prisma#2262)
Browse files Browse the repository at this point in the history
* fix: broken links in mdx files

* add: initial full-text search docs

* Update content/200-concepts/100-components/02-prisma-client/060-full-text-search.mdx

* Update content/200-concepts/100-components/02-prisma-client/060-full-text-search.mdx

* Update content/200-concepts/100-components/02-prisma-client/060-full-text-search.mdx

* Update content/200-concepts/100-components/02-prisma-client/060-full-text-search.mdx

* Added Admonition component example

* Addec code example

Co-authored-by: Nilu <nilubava@gmail.com>
Co-authored-by: Matthew Mueller <mattmuelle@gmail.com>
  • Loading branch information
3 people committed Sep 3, 2021
1 parent 5b5c6cc commit bcfc2e5
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
---
title: 'Full-Text Search'
metaTitle: 'Full-Text Search (Preview)'
metaDescription: 'This page explains how to use the prisma Preview feature full text search with a Postgres database.'
tocDepth: 2
preview: true
metaTitle: 'Full-Text Search'
metaDescription: 'This page explains how to search for text within a field.'
---

<TopBlock>
# Full-Text Search

Full-text search is available as a Preview feature in [2.30.0](https://github.com/prisma/prisma/releases/tag/2.30.0).

With 2.30.0 the Prisma Client supports a full-text search API for Postgres databases. Once enabled as a Preview feature, you can add search functionality to your application by searching for text within a database column.
The Prisma Client supports a full-text search API for Postgres databases. With full-text search enabled, you can add search functionality to your application by searching for text within a database column.

<Admonition type="info">
Note: Full text search can only be used in a Postgres database
**Note**: Full text search can **only** be used in a Postgres database
</Admonition>

</TopBlock>

## Enable full-text search

The full-text Search API is still in **Preview**. To enable `fullTextSearch`:
The full-text Search API is still in **Preview**. You can enable `fullTextSearch` in your Prisma Schema:

1. Update the [`previewFeatures`](../preview-features) block in your schema:
1: Update the [`previewFeatures`](../preview-features) block in your schema:

```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
}
```
```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
}
```

2. Generate the Prisma Client:
2: Generate the Prisma Client:

```terminal copy
npx prisma generate
```
```terminal copy
npx prisma generate
```

After you regenerate your client, a new `search` field will be available on any `String` fields created on your models.

### Example of new <inlinecode>search</inlinecode> field

```ts
````ts
// All posts that contain the words cat or dog.
const result = await prisma.posts.findMany({
where: {
Expand All @@ -60,7 +54,6 @@ const result = await prisma.posts.findMany({
},
},
})
```

## Query Format

Expand Down Expand Up @@ -91,7 +84,7 @@ easily add one yourself.

```sql
CREATE INDEX post_body_index ON posts USING GIN (body);
```
````
You can continue using Prisma Migrate as you were before, it will ignore indexes
that it doesn't know about.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ In this section you'll introspect your database to generate the Prisma models fo
provider = "postgresql"
url = env("DATABASE_URL")
}
model Post {
authorId Int?
content String?
Expand All @@ -407,7 +407,7 @@ In this section you'll introspect your database to generate the Prisma models fo
title String
User User? @relation(fields: [authorId], references: [id])
}
model User {
email String @unique
id Int @id @default(autoincrement())
Expand All @@ -425,7 +425,7 @@ In this section you'll introspect your database to generate the Prisma models fo
provider = "mysql"
url = env("DATABASE_URL")
}
model Post {
authorId Int?
content String?
Expand All @@ -434,7 +434,7 @@ In this section you'll introspect your database to generate the Prisma models fo
title String
User User? @relation(fields: [authorId], references: [id])
}
model User {
email String @unique
id Int @id @default(autoincrement())
Expand All @@ -460,7 +460,7 @@ You must manually add views to the Prisma schema.
provider = "mysql"
url = env("DATABASE_URL")
}
model Post {
authorId Int?
content String?
Expand All @@ -469,14 +469,14 @@ You must manually add views to the Prisma schema.
title String
User User? @relation(fields: [authorId], references: [id])
}
model User {
email String @unique
id Int @id @default(autoincrement())
name String?
Post Post[]
}
model Draft {
title String
id Int @unique
Expand All @@ -494,7 +494,7 @@ You must manually add views to the Prisma schema.
provider = "postgresql"
url = env("DATABASE_URL")
}
model Post {
authorId Int?
content String?
Expand All @@ -503,14 +503,14 @@ You must manually add views to the Prisma schema.
title String
User User? @relation(fields: [authorId], references: [id])
}
model User {
email String @unique
id Int @id @default(autoincrement())
name String?
Post Post[]
}
model Draft {
title String
id Int @unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,56 @@ Code:
</Tip>
```

## Admonition component

The Admonition shows a message to the user with different levels of priority.

- `info`: The message is informational.
- `warning`: The message is a warning.
- `alert`: The message is an alert.

### Info Example

<Admonition type="info">

This is some information that might be of use to the reader

</Admonition>

### Warning Example

<Admonition type="warning">

This is some information we want to warn the user about, maybe they should know this before they start using a feature.

</Admonition>

### Alert Example

<Admonition type="alert">

This is some information we want to alert the user to, maybe they should be aware of some **breaking changes**

</Admonition>

```tsx

<Admonition type="info">

This is some information that might be of use to the reader

</Admonition>

<Admonition type="warning">

This is some information we want to warn the user about, maybe they should know this before they start using a feature.

</Admonition>

<Admonition type="alert">

This is some information we want to alert the user to, maybe they should be aware of some **breaking changes**

</Admonition>
```

0 comments on commit bcfc2e5

Please sign in to comment.