feat: add $consider (UP/DOWN) toggle to query builder and evaluators

This commit is contained in:
M1
2026-03-16 13:56:36 +04:00
parent 5328471229
commit 27c9044a8b
3 changed files with 46 additions and 9 deletions
+8
View File
@@ -86,6 +86,14 @@ export function evaluate(query: unknown, ctx: EvalContext): boolean {
const q = query as Record<string, unknown>;
// $consider — "up" (default) or "down": flips result if conditions match
if ("$consider" in q) {
const consider = q.$consider as string;
const rest = Object.fromEntries(Object.entries(q).filter(([k]) => k !== "$consider"));
const matches = evaluate(rest, ctx);
return consider === "down" ? !matches : matches;
}
// $and
if ("$and" in q) {
const clauses = q.$and;