How do I get all data which has common data in some fields? I want to get all data with the same campaignID

  {
    "_id": "628b59f072d05a2d51b0a2e6",
    "campaignID": "61c6a74d0c61c7ef2aeb24d4",
    "data": [
      "628b59f072d05a2d51b0a2e2"
    ],
    "updated": "Mon May 23 2022 12:50:47 GMT+0300 (East Africa Time)",
    "__v": 0
  },
  {
    "_id": "628b59f272d05a2d51b0a2ed",
    "campaignID": "61c6a74d0c61c7ef2aeb24d4",
    "data": [
      "628b59f272d05a2d51b0a2e9"
    ],
    "updated": "Mon May 23 2022 12:50:47 GMT+0300 (East Africa Time)",
    "__v": 0
  },
  {
    "_id": "628b5a3c72d05a2d51b0a2f6",
    "campaignID": "61c6a74d0c61c7ef2aeb24d4",
    "data": [
      "628b5a3c72d05a2d51b0a2f2"
    ],
    "updated": "Mon May 23 2022 12:50:47 GMT+0300 (East Africa Time)",
    "__v": 0
  }

This is one of the most basic query.

db.collection.find( ­{ "campaignID": "61c6a74d0c61c7ef2aeb24d4" } )

I strongly recommend that you take MongoDB Courses and Trainings | MongoDB University.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.