api-query-params
api-query-params copied to clipboard
Bug with !=
We are having an issues with the !=
operator. When we try to query where _id!=64514704b973cc48c724d563
instead of resolving this as $ne
it instead is turning into $not
which happens at this line
The reason this triggers is becasue we have a caster for this field:
import { ObjectId } from 'mongodb';
const aqpOptions = {
casters: {
mongoId: (val) => new ObjectId(val),
},
castParams: {
_id: 'mongoId',
},
};
What I would like to know is when is the $not
operator intended to be added? In the documentation and examples I only see it next to regex values. Are there other cases where $not
should be added as well, or would it be safe to also check value instanceof RegExp
before using that condition?