feat: add $consider (UP/DOWN) toggle to query builder and evaluators
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user