October 2018
Intermediate to advanced
332 pages
8h 9m
English
Using the meta class variable, many attributes of a document can be manually set. If you are working with an existing set of data and want to connect your classes to the collections, then set the collection key of the meta dictionary, as follows:
class Post(mongo.Document):
...
meta = {'collection': 'user_posts'}
You can also manually set the maximum number of documents in the collection and the maximum size of each document. In the following example, there can be only 10,000 documents, and each document can't be larger than 2 MB:
class Post(mongo.Document):
...
meta = {
'collection': 'user_posts',
'max_documents': 10000,
'max_size': 2000000
}
Indexes can also be set through MongoEngine. Indexes can be made single field ...