1

I am running a python script to retrieve data from a mongo collection. I would like to use the "$nin" operator to retrieve all the fields from the collection except for the ones whose "UserID" is not like "xyz.com". Below is my script, I am running into a syntax error using the script. Could you please let me know how the "$nin" should be represented in pymongo ?

for data in db.userauthorization.find({'UserID':{"$nin":{[/'xyz.com'/]}}}):
    print data

Thanks in advance!

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
user3063530
  • 79
  • 1
  • 2
  • 11

1 Answers1

0

Try without "/" for data in db.userauthorization.find({'UserID':{"$nin":{['xyz.com']}}}): print data

Pierre
  • 21
  • 3