better docstring for BaseQuerySet.fields
This commit is contained in:
parent
5c3928190a
commit
2770cec187
@ -901,17 +901,23 @@ class BaseQuerySet(object):
|
|||||||
|
|
||||||
def fields(self, _only_called=False, **kwargs):
|
def fields(self, _only_called=False, **kwargs):
|
||||||
"""Manipulate how you load this document's fields. Used by `.only()`
|
"""Manipulate how you load this document's fields. Used by `.only()`
|
||||||
and `.exclude()` to manipulate which fields to retrieve. Fields also
|
and `.exclude()` to manipulate which fields to retrieve. If called
|
||||||
allows for a greater level of control for example:
|
directly, use a set of kwargs similar to the MongoDB projection
|
||||||
|
document. For example:
|
||||||
|
|
||||||
Retrieving a Subrange of Array Elements:
|
Include only a subset of fields:
|
||||||
|
|
||||||
You can use the $slice operator to retrieve a subrange of elements in
|
posts = BlogPost.objects(...).fields(author=1, title=1)
|
||||||
an array. For example to get the first 5 comments::
|
|
||||||
|
|
||||||
post = BlogPost.objects(...).fields(slice__comments=5)
|
Exclude a specific field:
|
||||||
|
|
||||||
:param kwargs: A dictionary identifying what to include
|
posts = BlogPost.objects(...).fields(comments=0)
|
||||||
|
|
||||||
|
To retrieve a subrange of array elements:
|
||||||
|
|
||||||
|
posts = BlogPost.objects(...).fields(slice__comments=5)
|
||||||
|
|
||||||
|
:param kwargs: A set keywors arguments identifying what to include.
|
||||||
|
|
||||||
.. versionadded:: 0.5
|
.. versionadded:: 0.5
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user