-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: "Cannot nest $ under $in" when querying Mongo IDs #231
Comments
Hmmm, your snippet works for me. Here's what I'm doing: const test = sift({ _id: { '$in': [ new ObjectID("610b6bc9e29dbd1bb5f045bf") ] } })
assert.equal(test({ _id: new ObjectID("610b6bc9e29dbd1bb5f045bf") }), true); I'm guessing that the |
Hi, The snippet I added above:
|
Ran into the same issue.... What I"m seeing is that this fails because it's looking at object "proto" properties in the following comparison function, thus finding a match on "toString" which exists in both.
Have you considered using the following ? I think that would eliminate the issue I'm seeing at least.
I can see in version 13.5.4, that this issue was mitigated by the following code, which explicitly looked for fields whose name started with a "$". That logic was removed in 14.x, which is why this issue surfaced.
|
Thanks for the suggestion! This should be up on NPM as |
Closing since this should be fixed now. |
Hi,
I use this library in conjunction with the DataLoader library (like many others I'm sure). I have a batching function that takes a number of filters, runs a single query on mongo, and then uses sift to 'unbatch' the results
In other words I'm using the same filter to find Mongo documents as for filtering a JavaScript array using sift. This worked with versions prior 14 despite that sift needed to match objects to objects (auto-generated _ids in Mongo).
Since updating to v14 my batching functions fail.
v13.5.4
This works
In
v14.02
, for the same expression sift throws an error:The text was updated successfully, but these errors were encountered: