Better performance: The Cursor class is not wrapped anymore so the overhead of instanciating Documents instead of dicts is now close to zero.

Requires pymongo 3.0+, taking advantage of its new features. To make transition to 3.0 easier (lots of pymongo’s APIs got renamed or deprecated) MongoKat still supports some 2.x-style parameters and method names.

Support for simple hooks:before_delete, after_delete, after_save. Useful for keeping data up-to-date in ElasticSearch for instance, on a best-effort basis (some hooks may be lost under high load when using methods like update_many).

Support for protected fields that can’t be updated directly. Useful for making sure developers to use specific methods of a Document.

# First, declare a Document/Collection pair (a "model"):frommongokatimportCollection,DocumentclassSampleDocument(Document):defmy_sum(self):returnself["a"]+self["b"]classSampleCollection(Collection):document_class=SampleDocumentdeffind_by_a(self,a_value):returnself.find_one({"a":a_value})# Then use it in your code like this:frompymongoimportMongoClientclient=MongoClient()Sample=SampleCollection(collection=client.my_db.my_col)Sample.insert({"a":1,"b":2})Sample.insert({"a":2,"b":3})assertSample.count()==2five=Sample.find_by_a(2)assertfive.my_sum()==5

return all document which match the structure of the object
fetch() takes the same arguments than the the pymongo.collection.find method.
The query is launch against the db and collection of the object.

return one document which match the structure of the object
fetch_one() takes the same arguments than the the pymongo.collection.find method.
If multiple documents are found, raise a MultipleResultsFound exception.
If no document is found, return None
The query is launch against the db and collection of the object.