mongo
mongo copied to clipboard
Scalar Attribute Proxies
Getting this idea out of my brain onto "paper" while it's fresh, permit the return of scalar attribute proxies from find_one()
, that is, an apparent instance of the targeted Document
sub–class that upon access to an attribute (field descriptor) or subscript (dictionary-like access redirected to the underlying backing dict), performs the query needed to retrieve just that value. Example name, following the overall naming pattern: find_scalar()
This may be more natural than pre-defining an iterable of fields to retrieve, then unpacking a resulting tuple of those retrieved values. (Sometimes you don't want your data cached application-side… but still want the benefit of those descriptor objects.)