feathersjs-ecosystem / feathers-mongoose

Easily create a Mongoose Service for Feathersjs.
MIT License
189 stars 96 forks source link

feathersjs-mongoose doesn't support $elemMatch as query. #434

Open prescripson opened 2 years ago

prescripson commented 2 years ago

My MongoDB document is like

image

I am trying to replicate that query with feathers-mongoose service find method.

Expected behabiour should be matched count 0, as in the original document the objectId 62ed2315399edd80209a502a only have create in the allow field array.

In MongoDB compass after execute the query the result become No Matchd ( Expected )

image

But, in feathers-mongoose service it returns with single match item. ( unexpected )

 async find(params?: Params | undefined): Promise<any[] | Paginated<any>> {
      return await super.find({query: {manage: {$elemMatch: {_id: new mongoose.Types.ObjectId('62ed2315399edd80209a502a'), allow: 'read'}}}})
  }

Although above code is just for demostration, in real scenario those queries are added by feathers-casl.

image