payload
Version:
Node, React, Headless CMS and Application Framework built on Next.js
18 lines (17 loc) • 583 B
JavaScript
/**
* Take a where query and flatten it to all top-level operators
*/ export function flattenWhereToOperators(query) {
const result = [];
for (const [key, value] of Object.entries(query)){
if ((key === 'and' || key === 'or') && Array.isArray(value)) {
for (const subQuery of value){
const flattenedSub = flattenWhereToOperators(subQuery);
result.push(...flattenedSub);
}
} else {
result.push(value);
}
}
return result;
}
//# sourceMappingURL=flattenWhereToOperators.js.map