Lun*_*ndd 5 javascript postgresql typescript supabase supabase-database
我尝试过使用许多符号来分隔列;||、|、&&、&(带空格和不带空格)。
例如
.textSearch("username, title, description", "...");
.textSearch("username|title|description", "...");
Run Code Online (Sandbox Code Playgroud)
但没有任何效果:(
您可以创建一个 SQL 函数来执行搜索,如下所示:
create or replace function search_posts(keyword text)
returns setof posts
as
$func$
select
*
from
posts
where
to_tsvector(username || ' ' || title || ' ' || description) -- concat columns, but be sure to include a space to separate them!
@@ to_tsquery(keyword);
$func$
language sql;
Run Code Online (Sandbox Code Playgroud)
你可以这样调用这个函数:
const {data, error} = await supabase.rpc('search_posts', { keyword: '[YOUR_SEARCH_TERM_HERE]' })
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3573 次 |
| 最近记录: |