feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.08k stars 750 forks source link

$in query with mongoDB - difference between 5.0.23 and 5.0.24 #3467

Open martinfruehmorgen opened 7 months ago

martinfruehmorgen commented 7 months ago

Hello, did anybody recognize a difference between feathers 5.0.23 vs 5.0.24 using $in-query with mongodb-objectIDs?

In v23 a query

app.service('messages').find({
  query: {
    roomId: {
      $in: ['62759ea6b884f9180816bfb1', '62759ea6b884f9180816bfc1']
    }
  }
})

while roomId is a ObjectIdSchema() in the scheme worked.

In v24 I need to change the messagesQueryProperties manually to

roomId: Type.Union([
    // an object with { $in: ObjectId[] }
    Type.Partial(
      Type.Object({
        $in: Type.Array(ObjectIdSchema())
      })
    ),
    // an ObjectId by itself
    ObjectIdSchema()
  ])

to get the query work.

NodeJS version: 20.11.0

Operating System: Windows 11

Browser Version: Edge Version 123.0.2420.97 (Offizielles Build) (64-Bit)

Thank you! Martin

sainf commented 7 months ago

I have the same problem with using query ObjectIdShema with $ne.

Logging the query after serviceQueryResolver

daffl commented 7 months ago

I don't know what would've changed here. Whatever it is, it looks like the tests in https://github.com/feathersjs/feathers/blob/dove/packages/mongodb/test/converters.test.ts#L41 didn't catch it.