Find $in filter - works in shell but not work in NodeJS

This is my filter I successfully used this with shell. got three documents from the shell.

{
  resource_Target_Uuid: {
    '$in': [
      'd10b30f6-7a14-4a00-9433-d814db87506a',
      '0cd05a65-4455-49b2-a4a3-812331e9f8e4',
      '6c23a559-44f5-4fb6-8ac3-e80f060243f0'
    ]
  }
}

However, it didn’t work in NodeJS - it gives nothing - any idea why it works differently?

FindCursor {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,

By the way, findOne is working…

console [Tue May 24 2022 16:43:15] [LOG]   {
  _id: new ObjectId("628d1ed357185223f9837572"),
  resource_Type: 'ND',
  resource_Group_Uuid: '0b73a502d4ba48339bd7605b46a79b43',
  resource_Name: 'new-node-c7g94',

found the solution… you should use find(query).toArray() instead of find(query)… in NodeJS. …

1 Like