run yarn add --dev ez-query-builder-mongo
or npm i --save-dev ez-query-builder-mongo
import { queryBuilder } from "ez-query-builder-mongo";
const params = {
_or: [
{ _and: [{ name: "Eder" }, { age_in: [22, 23] }] },
{ _and: [{ name: "Zadravec" }, { age_in: [22, 23] }] },
{ hasCar: true}
]
};
queryBuilder(params)
{
$or: [
{
$and: [
{
name: "Eder"
},
{
age: {
$in: [
22,
23
]
}
}
]
},
{
$and: [
{
name: "Zadravec"
},
{
age: {
$in: [
22,
23
]
}
}
]
},
{
hasCar: true
}
]
}