I've got the following problem. I don't seem to figure out on how to access the "UID" value within the warning field. I want to iterate over every value inside the document, and access every existing UID to check if a randomly generated UID already exists. I'm honestly about to have a mental breakdown due this, I just can't seem to figure it out
This is what my MongoDB structure looks like: https://i.stack.imgur.com/RmdMT.png
warnings will be a list after you've got the object in python code - so you can just iterate over the docs in the
warningslist and access theirUIDkeysedited code for comments: We can get all the documents in the collection by using
findwith an empty query dict, though I've linked the docs on find below. As your document structure seems to have a random number as a key, and then an embedded doc, we find the keys in the document that aren't_id. It may be that there's only one key, but I didn't want to assume. If there's then awarningskey in our embedded doc, we iterate over each of the warnings and add the "UID" to ourwarning_uidslist.