Answers for "mongodb match on multiple fields"

Go
0

mongodb match multiple fields

$match:
{
	$and: [
    {'ExtraFields.value': {$in: ["A52A2A"]}}, 
    {'ExtraFields.fieldID': ObjectId("5535627631efa0843554b0ea")}
    ]
}
Posted by: Guest on July-01-2020
0

mongodb lookup multiple fields

db.collection2.aggregate([
       {
          $lookup: {
             from: "collection1",
             let: {
                firstUser: "$user1",
                secondUser: "$user2"
             },
             pipeline: [
                {
                   $match: {
                      $expr: {
                         $and: [
                            {
                               $eq: [
                                  "$user1",
                                  "$$firstUser"
                               ]
                            },
                            {
                               $eq: [
                                  "$user2",
                                  "$$secondUser"
                               ]
                            }
                         ]
                      }
                   }
                }
             ],
             as: "result"
          }
       },
       {
          $replaceRoot: {
             newRoot: {
                $mergeObjects:[
                   {
                      $arrayElemAt: [
                         "$result",
                         0
                      ]
                   },
                   {
                      percent1: "$$ROOT.percent1"
                   }
                ]
             }
          }
       }
    ]
)
Posted by: Guest on March-09-2021

Code answers related to "mongodb match on multiple fields"

Browse Popular Code Answers by Language