MCPcopy Create free account
hub / github.com/subquery/subql / createSearchFunctionQuery

Function createSearchFunctionQuery

packages/node-core/src/db/sync-helper.ts:744–754  ·  view source on GitHub ↗
(schema: string, table: string)

Source from the content-addressed store, hash-verified

742export const dropSearchFunctionQuery = (schema: string, table: string): string =>
743 dropFunction(schema, searchFunctionName(schema, table));
744export const createSearchFunctionQuery = (schema: string, table: string): string => {
745 const functionName = searchFunctionName(schema, table);
746 return `
747create or replace function ${escapedName(schema, functionName)}(search text)
748 returns setof ${escapedName(schema, table)} as $$
749 select *
750 from ${escapedName(schema, table)} as "table"
751 where "table"."${TS_VECTOR_COL}" @@ to_tsquery(search)
752 $$ language sql stable;
753 `;
754};
755
756export const commentSearchFunctionQuery = (schema: string, table: string): Query =>
757 commentOnFunction(schema, searchFunctionName(schema, table), `@name search_${table}`);

Callers

nothing calls this directly

Calls 2

searchFunctionNameFunction · 0.85
escapedNameFunction · 0.85

Tested by

no test coverage detected