Utility classes/functions for using MongoDB
Formats outgoing documents as ReachableDoc, so that embedded documents can be addressed with dot notation directory.
e.g., doc[‘firstkey.secondkey’] = value
ReachableDoc manipulates overrides dict __getitem__ behaviour to allow embedded documets to be accessed with dot notation in the keys.
Factory for MongoDB connections.
This function will attempt to connect to the named server, and fall back to the URL and port settings if a server is not named.
Parameters: | server : str
url : str
port : int
|
---|---|
Returns: | connection : obj
|
Returns a value from an embedded document.
>>> embeddedDict = {"first": {"second": "gold!"}}
>>> reach(embeddedDict, "first.second")
gold!
Parameters: | doc : dict compatible
key : str
|
---|