I have a subobject in a mongo database with fields that contain spaces, something like:
{name: "John Doe", subdata: {"Field 1": "Something", "Field 2": "Something else"}}
From what I’ve been able to find, mongo allows the fields Field 1 and Field 2, but I haven’t been able to find any indication of how to structure a query to look for subdata.Field 1. Is there a way I could search for Field 1 and Field 2 in my example, or should I restructure my data to get rid of white spaces?
Well, I don’t know about pymongo, but many libraries for other languages offer object-document mapping functionality. I bet you’ll have problems with this as well, because “Field 1” is an invalid identifier in every language I heard of.
My advice: get rid of whitespaces, you’ll save a great amount of time in the future.