I need to create a query in mongoose paginate V2 whit or operator, suppose I have a collection "employees" like this:
[{
"firstName": "Jhon",
"lastName": "Doe",
"monthlyIncome": 50
},
{
"firstName": "Jhon",
"lastName": "Smith",
"yearlyIncome": 100
},
{
"firstName": "Emma",
"lastName": "Jhonson",
"weeklyIncome": 20
}]
I want to retrieve all the employees who receive 50 or more either a week a month or a year. If I run the following query in console (or without moongose paginate v2 plugin), it returns the first two documents
db.employee.find({
$or: [
{monthlyIncome: {$gte: 50}},
{yearlyIncome: {$gte: 50}},
{weeklyIncome:{$gte: 50}}
]})
How can i do the same with mongoose paginate V2?
I use a var newQuery to construct the query
let newQuery = {}
And use it after in:
let result = await employees.paginate(newQuery, {
page:1,
limit: 10
}).then()