Home > Net >  Filter mongo document in django
Filter mongo document in django

Time:02-10

The project stack is Django MongoDB (djongo library).
I have product table with data structure like this

{
  _id:"qwer1234",
  organization:{...},
  service:{
      "id":1,
      ...
 
  }
}

How can I get all documents where service.id will be in array of id ([1,2,3])?

CodePudding user response:

Simply use $in like this:

db.collection.find({
  "service.id": {
    "$in": yourArray
  }
})

Check this example

  • Related