Evaluates the compiled filter AST in memory: a plain (row) => boolean predicate with the
same semantics as the SQL adapters, a sort comparator, and synchronous offset/cursor
pagination over arrays. Zero dependencies; safe for the frontend.
buildFilterPredicate / buildFilterNodePredicate compile and render in one step,
toFilterPredicate renders a pre-compiled CompiledWhere, applyFiltersToArray filters an
array, buildComparator turns a Sort into an Array.prototype.sort comparator, and
createMemoryKeyset / createMemoryPaginator page through the result. Matching follows SQL:
three-valued NULL logic (ne/notInArray/notIlike never match NULL, not keeps UNKNOWN),
LIKE patterns with %/_/\ escapes, and case folding, NULL ordering and NULL arrays per
dialect ("postgres", the default, or "sqlite"). A cross-adapter test checks it returns
the same rows as the knex, kysely and drizzle adapters on SQLite.
Compile filters with buildFilterPredicate and return the rows that match, as a new array in their original order. The array counterpart of applyFiltersToKnex.
Build an Array.prototype.sort comparator from a Sort, allow-listed to paths (public field name → MemoryAccessor). Unknown fields are dropped; when nothing is left, defaultSort is used instead (and with no keys at all every pair compares equal). Keys apply in order; ties keep the input order, since Array.prototype.sort is stable.
Compile a flat, AND-combined list of column filters into a row predicate. Only fields in spec whose kind matches the filter’s kind are kept; the rest are silently dropped, and when nothing survives the predicate matches every row. A date preset filter needs resolveDate (it throws without one). dialect (default "postgres") picks the SQL semantics to copy (see MemoryDialect).
Build a keyset (cursor) helper over in-memory rows from a sort spec (the same { key, order }[] as createKeysetSpec, whose seek AST it evaluates). Each key reads paths[key], or the key itself as a path. The last key MUST be unique (a tiebreaker like id) so the cursor is stable.
Create a fully synchronous paginator over an in-memory array (createPaginator from @xtandard/lib/pagination with array fetchers): page/offset requests slice the sorted rows (and report totalItems), cursor requests seek with createMemoryKeyset, forward or backward. paginate returns a plain Paginated<Row> (no await), so it works in a render path. The rows are copied and sorted once, at creation; filter them first (for example with applyFiltersToArray).
Render an already-compiled CompiledWhere AST (from compileFilters / compileFilterNode in @xtandard/lib/filters) to a row predicate, looking each field up in paths (public field name → MemoryAccessor). Conditions on fields missing from paths are dropped; null (or an AST that drops to nothing) gives a predicate that matches every row. Evaluation uses SQL’s three-valued logic: a comparison with NULL is UNKNOWN, not keeps UNKNOWN, and a row matches only when the whole tree is TRUE. Most code calls buildFilterPredicate, which compiles and renders in one step.
What a field reads from a row: a property key or dot path ("name", "address.city", like the mongo adapter’s path), or a getter function (like a raw expression in the kysely adapter). Accessors are server-owned: never build one from request data.
Allow-list a public field as an array filter over a row value read by path that holds an array. arrayContains is Postgres @> (the row has every value), arrayContained is <@ (every row element is a value) and arrayOverlaps is && (at least one in common).
Allow-list a public field as a date filter over a row value read by path (a key, a dot path, or a getter). The row value may be a Date, an ISO-8601 string, epoch milliseconds, or any object with a numeric epochMilliseconds (Temporal.Instant, Temporal.ZonedDateTime). A date preset needs the resolveDate you pass to buildFilterPredicate, and becomes a half-open [start, end) window.
Allow-list a public field as an enum filter (eq/ne/inArray/notInArray/null checks) over a row value read by path. As in SQL, ne and notInArray never match a NULL.
Allow-list a public field as a number filter over a row value read by path (a key, a dot path, or a getter). between matches >= from and <= to; a bigint row value compares numerically.
Allow-list a public field as a text filter over a row value read by path (a key, a dot path, or a getter). contains/startsWith/endsWith match the input literally and ignore case; like/ilike/notIlike take a SQL pattern (%, _, \ escapes). How case is folded follows dialect (see MemoryDialect).