N1QL Queries¶
-
class
couchbase.cluster.
QueryScanConsistency
[source]¶ -
.. autodata:: NOT_BOUNDED
-
.. autodata:: REQUEST_PLUS
-
class
couchbase.mutation_state.
MutationState
(*docs)[source]¶ Warning
The API and implementation of this class are subject to change.
This class acts as a container for one or more mutations. It may then be used with the
consistent_with()
method to indicate that a given query should be bounded by the contained mutations.Using consistent_with is similar to setting
consistency
toREQUEST_PLUS
, but is more optimal as the query will use cached data, except when the given mutation(s) are concerned. This option is useful for use patterns when an application has just performed a mutation, and wishes to perform a query in which the newly-performed mutation should reflect on the query results.Note
This feature requires Couchbase Server 4.5 or greater, and also requires that enable_mutation_tokens=true be specified in the connection string when creating a
Client
cb = Bucket('couchbase://localhost/default?enable_mutation_tokens=true') rvs = cb.upsert_multi({ 'foo': {'type': 'user', 'value': 'a foo value'}, 'bar': {'type': 'user', 'value': 'a bar value'} }) nq = _N1QLQuery('SELECT type, value FROM default WHERE type="user"') ms = MutationToken() ms.add_result(rv nq.consistent_with_ops(*rvs.values()) for row in cb.n1ql_query(nq): # ...
-
class
couchbase.n1ql.
QueryResult
[source]¶ -
__init__
(self, params, parent, **kwargs)[source]¶ Object representing the execution of the request on the server.
Warning
You should typically not call this constructor by yourself, rather use the
n1ql_query()
method (or one of its async derivatives).- Parameters
params – An
_N1QLQuery
object.parent – The parent
Client
objectrow_factory – Callable which accepts the raw dictionary of each row, and can wrap them in a customized class. The default is simply to return the dictionary itself.
To actually receive results of the query, iterate over this object.
-