Filters playground
This page runs the real @xtandard/lib/filters code in your browser. It uses an example
products resource with one field of each kind. Edit the JSON and switch tabs to see:
- SQL (Knex): the parameterized
WHEREfrom@xtandard/lib/filters/knexfor Postgres, MySQL or SQLite. - Mongo / Prisma: the plain filter objects the driver-free adapters build.
- PostgREST: the query string from
@xtandard/lib/filters/postgrest(what supabase-js would send). - Elasticsearch: the Query DSL clause from
@xtandard/lib/filters/elasticsearch. - Compiled AST: the portable
CompiledWhereevery adapter renders from. - Compact URL: the shorter wire form from
compactFilters/compactFilterNode. - Chip labels:
describeColumnFilteroutput for an active-filter bar.
-- parameterized
WHERE ("products"."name" ILIKE ? AND ("products"."price" >= ? AND "products"."price" <= ?) AND "products"."status" IN (?, ?))
-- bindings: [ "%lamp%", 10, 100, "active", "draft" ]
-- inlined for reading
WHERE ("products"."name" ILIKE '%lamp%' AND ("products"."price" >= 10 AND "products"."price" <= 100) AND "products"."status" IN ('active', 'draft'))The spec behind this page, as you would write it for the Knex adapter:
import { arrayField, booleanField, buildWhereSql, dateField, enumField, numberField, textField,} from "@xtandard/lib/filters/knex";
const spec = { name: textField({ column: "products.name" }), status: enumField({ column: "products.status" }), price: numberField({ column: "products.price" }), inStock: booleanField({ column: "products.in_stock" }), tags: arrayField({ column: "products.tags" }), createdAt: dateField({ column: "products.created_at" }),};
const fragment = buildWhereSql({ spec, filters, resolveDate, dialect: "postgres" }); // { sql, bindings } | null