Hasty Briefsbeta

Show HN: FilterQL – A tiny query language for filtering structured data

17 days ago
  • #data-filtering
  • #query-language
  • #typescript
  • FilterQL is a tiny query language for filtering structured data.
  • It consists of a TypeScript library and a language specification, with implementations in other languages welcome.
  • Install via `bun add filterql` or `npm install filterql`.
  • Define a schema for your data to specify allowed fields and their types, including optional aliases.
  • Filter data using comparisons like `==`, `!=`, `*=`, `^=`, `$=`, `~=`, `>=`, `<=`.
  • Logical operators `&&`, `||`, `!`, and parentheses `()` can combine comparisons for complex queries.
  • Boolean fields can be checked directly, e.g., `monitored` is equivalent to `monitored == true`.
  • Case-insensitive comparisons can be made by prefixing operators with `i`, e.g., `title i== interstellar`.
  • Values with spaces or special characters must be quoted, with internal quotes escaped.
  • Filter for empty values using `rating == ""` or non-empty with `rating != ""`.
  • Use `*` to skip filtering and apply operations directly.
  • Operations like `SORT` and `LIMIT` can transform data post-filtering.
  • Custom operations can be defined by providing functions to the `FilterQL` constructor.
  • The schema enforces field types (string, number, boolean) and can disallow unknown fields.
  • FilterQL's grammar includes detailed rules for tokenization, operator precedence, and syntax.