[Question, Help needed] AND operator
Hello, Is it possible, to have something like this:
query({
attractions: { type: [String], paths: ['attractions'], multiple: true },
categories: { type: [String], paths: ['category'], multiple: true },
search: {
type: RegExp,
paths: ['name', 'description', 'city', 'street']
}
}),
And that would I like to have, is to match all of the rules, for example, if attractions and categories are specified, I'd like to have only objects which match both of the rules.
Same for search functionality, both filters should be applied (attractions and categories), then the search regex.
I have the same question, I need it to obtain documents between certain dates. I did this but it didn't work:
after: {
type: Date,
paths: ['fecha'],
operator: '$gte'
},
before: {
type: Date,
paths: ['fecha'],
operator: '$lte'
}
I really need to use AND Operator.
i have the same question. i try it.
first, querymen schema setup before express router code.
import { Schema as QuerymenSchema } from 'querymen'
const qms = new QuerymenSchema({
createdAtDate: { type: Date, paths: ['createdAt'], duration: 'date', },
})
qms.parser('duration', (duration, value, path, operator) => {
if (!value) { return value }
if (duration == 'date') {
value = { [path]: { '$gte': new Date(value.setHours(0,0,0,0)), '$lte': new Date(value.setHours(23,59,59,999)), } }
}
return value
})
then, you try router setup.
router.get('/',
query(querySchema),
index)
that's easy? (always, Diegohaz is great. greatness.)