docs(guides/database/full-text-search) update searching multiple columns guide

Update searching multiple columns guide with a workaround involving
This commit is contained in:
Khairul Haaziq authored and GitHub committed 2023-03-20 00:46:17 +08:00
1 parent cff623e010
commit db64266bf3
1 file changed
+35
@@ -227,6 +227,9 @@ final result = await client
### Search multiple columns
Right now there is no direct way to use Javascript or Dart to search through multiple columns. A workaround exist where using SQL is required.
The method involves creating [computed virtual columns](https://postgrest.org/en/stable/api.html#computed-virtual-columns).
To find all `books` where `description` or `title` contain the word `little`:
<Tabs
@@ -247,6 +250,38 @@ where
@@ to_tsquery('little');
```
</TabPanel>
<TabPanel id="js" label="JavaScript">
```sql
CREATE FUNCTION title_description(books) RETURNS text AS $$
SELECT $1.title || ' ' || $1.description;
$$ LANGUAGE SQL;
```
```js
const { data, error } = await supabase
.from('books')
.select()
.textSearch('title_description', `little`)
```
</TabPanel>
<TabPanel id="dart" label="Dart">
```sql
CREATE FUNCTION title_description(books) RETURNS text AS $$
SELECT $1.title || ' ' || $1.description;
$$ LANGUAGE SQL;
```
```dart
final result = await client
.from('books')
.select()
.textSearch('title_description', "little")
```
</TabPanel>
<TabPanel id="data" label="Data">