api-query-params icon indicating copy to clipboard operation
api-query-params copied to clipboard

Bug with !=

Open lc-mm opened this issue 1 year ago • 0 comments

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?

lc-mm avatar May 02 '23 17:05 lc-mm