parent
6eb0387a78
commit
bbd3a6961e
@ -22,7 +22,7 @@ function. The only argument we need to provide is the name of the MongoDB
|
||||
database to use::
|
||||
|
||||
from mongoengine import *
|
||||
|
||||
|
||||
connect('tumblelog')
|
||||
|
||||
For more information about connecting to MongoDB see :ref:`guide-connecting`.
|
||||
@ -112,7 +112,7 @@ link table, we can just store a list of tags in each post. So, for both
|
||||
efficiency and simplicity's sake, we'll store the tags as strings directly
|
||||
within the post, rather than storing references to tags in a separate
|
||||
collection. Especially as tags are generally very short (often even shorter
|
||||
than a document's id), this denormalisation won't impact very strongly on the
|
||||
than a document's id), this denormalisation won't impact very strongly on the
|
||||
size of our database. So let's take a look that the code our modified
|
||||
:class:`Post` class::
|
||||
|
||||
@ -265,5 +265,5 @@ the first matched by the query you provide. Aggregation functions may also be
|
||||
used on :class:`~mongoengine.queryset.QuerySet` objects::
|
||||
|
||||
num_posts = Post.objects(tags='mongodb').count()
|
||||
print 'Found % posts with tag "mongodb"' % num_posts
|
||||
|
||||
print 'Found %d posts with tag "mongodb"' % num_posts
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user