mongodb - How to test for ObjectID vs just hex string in python -


i'm trying write generic method querying 1 mongodb collection (a) ids separate mongodb collection (b). here's have far:

def getothercollinfo(self, othercollobj, queryfield, outputfield="_id"):      selfidlist = self.getids() # gets set of ids whole collection (b)     returned_dict = {}     selfid in selfidlist:         curs_obj = othercollobj.find({queryfield : str(selfid)}).distinct(outputfield) #othercollobj 'collection (a)         temp_list=[]         obj in curs_obj:             temp_list.append(obj)             returned_dict[selfid]=temp_list     return returned_dict 

this works fine collection query_field looks like:

542de00c763f4a7f558be12f 

when attempting method on third collection (c), fails (i think) because query_field hex sting:

objectid('542de00c763f4a7f558be12f') 

is there way test formatting of id can make method more generic?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -