feat: grouped query builder with $upIf/$downIf condition groups

This commit is contained in:
M1
2026-03-16 13:52:06 +04:00
parent b20f463d53
commit 99b59070a2
4 changed files with 168 additions and 3 deletions
+7
View File
@@ -86,6 +86,13 @@ export function evaluate(query: unknown, ctx: EvalContext): boolean {
const q = query as Record<string, unknown>;
// $upIf / $downIf — named condition groups, $downIf takes precedence
if ("$upIf" in q || "$downIf" in q) {
if ("$downIf" in q && evaluate(q.$downIf, ctx)) return false;
if ("$upIf" in q) return evaluate(q.$upIf, ctx);
return true; // only $downIf set and it didn't match → up
}
// $and
if ("$and" in q) {
const clauses = q.$and;