Postgres Search Condition Builder (postgres-sql/search.ts)

langfuse · packages/shared/src/server/queries/postgres-sql/search.ts · typescript · MIT
database, search

Builds Prisma SQL ILIKE search conditions across id, content, input, and output columns with escaped patterns. Reuse when adding full-text search to raw Postgres queries.

// Source: https://github.com/langfuse/langfuse | License: MIT | Copyright 2023-2026 ClickHouse, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { Prisma } from "@prisma/client";
import { TracingSearchType } from "../../../interfaces/search";
import { escapeSqlLikePattern } from "../../utils/sqlLike";

/**
 * Builds PostgreSQL search condition for full-text search using ILIKE.
 * Returns Prisma.sql for use in raw queries, or Prisma.empty if no search query provided.
 *
 * Missing column definitions make it obvious which search types are NOT supported:
 * - If `contentColumns.content` is missing/empty → "content" search is not supported
 * - If `contentColumns.input` is undefined → "input" search is not supported
 * - If `contentColumns.output` is undefined → "ou

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key