Posts

Showing posts with the label MongoDB tip

MongoDB tip: Mongo web shell

Perhaps this has been around for sometime, but as soon as I saw it, I just wanted to make a copy here,.I got it from here   Mongo web shell! simply click connect, and anyone can use this to get some practice on navigating through mongo shell!  Enjoy!

MongoDB tip: comparing field cross collection using python

Image
The goal is to find anything that's in col2, but not in col1. col1 contains the following col2 contains the following Note, the field to compare in both collection need not to be in order as seen in the images. Again, I am trying to find what's missing in the first set from the second set.  from pymongo import MongoClient import bson client=MongoClient(host="mongodb://10.155.228.75:21001") db=client.testJoe col1=db.col1.distinct("compID"); col2= db.col2.distinct("compID"); col1= [int(x) for x in col1] x = set(col2) - set(col1) print(int(list(x)[0])) we see the output is 7, which is the missing number from col1