Like this project? it on
Query Sets¶
Query sets are used to work with sets of objects that have been retrieved from the database. For example, whenever you call the filter function of the backend, you will receive a QuerySet object in return. This object stores references to all documents matching your query and can retrieve these objects for you if necessary.
This class is an abstract base class that gets implemented by the specific backends.
-
class
blitzdb.queryset.
QuerySet
(backend, cls)[source]¶ Stores information about objects returned by a database query and retrieves instances of these objects if necessary.
Parameters: - backend – The backend to use for :py:meth:filter`filtering` etc.
- cls – The class of the documents stored in the query set.
-
__eq__
(other)[source]¶ Checks if two query sets are equal. Implement this in your derived query set class.
Parameters: other – The object this query set is compared to.
-
__getitem__
(i)[source]¶ Returns a specific element from a query set.
If i is a slice instead of an index (e.g. qs[:50]), returns a subset of the query results. This allows user to specify an offset and/or limit for the query.
-
__ne__
(other)[source]¶ Checks if two query sets are unequal.
Parameters: other – The object this query set is compared to.
-
filter
(*args, **kwargs)[source]¶ Performs a filter operation on all documents contained in the query set. See
blitzdb.backends.base.Backend.filter()
for more details.