Convert ObjectID to String in mongo Aggregation

后端 未结 5 1266
我在风中等你
我在风中等你 2021-02-05 12:15

I\'m in this scenario right now: I have a collection X:

{
  _id:ObjectId(\'56edbb4d5f084a51131dd4c6\'),
  userRef:ObjectId(\'56edbb4d5f084a51131dd4c6\'),
  seria         


        
5条回答
  •  感动是毒
    2021-02-05 12:39

    I think you may try to resolve it by using an Array which contains both fields:

    {$project:{newkey:['$userRef','$serialNumber']},{$match:{newkey:{$in:filterArray}}}}
    

    this may match the data with both fields to the filter. Please notice that the data in the newkey array should have the same data type with the filterArray elements.

提交回复
热议问题