Queryset

class yadm.queryset.BaseQuerySet(db, document_class, *, cache=None, criteria=None, projection=None, sort=None, slice=None, collection_params=None)

Query builder.

Parameters:
  • db
  • document_class
  • cache
  • criteria (dict) –
  • projection (dict) –
  • sort (list) –
  • slice (slice) –
  • collection_params (dict) –
cache

Queryset cache object.

copy(*, cache=None, criteria=None, projection=None, sort=None, slice=None, collection_params=None)

Copy queryset with new parameters.

Only keywords arguments is alowed. Parameters simply replaced with given arguments.

Parameters:
  • cache
  • criteria (dict) –
  • projection (dict) –
  • sort (list) –
  • slice (slice) –
  • collection_params (dict) –
Returns:

new yadm.queryset.QuerySet object

fields(*fields)

Get only setted fields.

Update projection with fields.

Parameters:fields (str) –
Returns:new yadm.queryset.QuerySet
qs('field', 'field2')
fields_all()

Clear projection.

find(criteria=None, projection=None)

Return queryset copy with new criteria and projection.

Parameters:
  • criteria (dict) – update queryset’s criteria
  • projection (dict) – update queryset’s projection
Returns:

new yadm.queryset.QuerySet

qs({'field': {'$gt': 3}}, {'field': True})
read_preference(read_preference)

Setup readPreference.

Return new QuerySet instance.

Deprecated since 1.4.0. Use collection_params argument in copy.

read_primary(preferred=False)

Return queryset with setupd read concern for primary.

If preferred argument is True, PrimaryPreferred is used else Primary.

sort(*sort)

Return queryset with sorting.

Parameters:sort (tuples) – tuples with two items: (‘field_name’, sort_order_as_int).
qs.sort(('field_1', 1), ('field_2', -1))
class yadm.queryset.NotFoundBehavior

An enumeration.