MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / get

Method get

couchbase/collection.py:121–166  ·  view source on GitHub ↗

Retrieves the value of a document from the collection. Args: key (str): The key for the document to retrieve. opts (:class:`~couchbase.options.GetOptions`): Optional parameters for this operation. **kwargs (Dict[str, Any]): keyword arguments that can be u

(self,
            key,  # type: str
            *opts,  # type: GetOptions
            **kwargs,  # type: Dict[str, Any]
            )

Source from the content-addressed store, hash-verified

119 return self._impl.name
120
121 def get(self,
122 key, # type: str
123 *opts, # type: GetOptions
124 **kwargs, # type: Dict[str, Any]
125 ) -> GetResult:
126 """Retrieves the value of a document from the collection.
127
128 Args:
129 key (str): The key for the document to retrieve.
130 opts (:class:`~couchbase.options.GetOptions`): Optional parameters for this operation.
131 **kwargs (Dict[str, Any]): keyword arguments that can be used in place or to
132 override provided :class:`~couchbase.options.GetOptions`
133
134 Returns:
135 :class:`~couchbase.result.GetResult`: An instance of :class:`~couchbase.result.GetResult`.
136
137 Raises:
138 :class:`~couchbase.exceptions.DocumentNotFoundException`: If the key provided does not exist
139 on the server.
140
141 Examples:
142
143 Simple get operation::
144
145 bucket = cluster.bucket('travel-sample')
146 collection = bucket.scope('inventory').collection('airline')
147
148 res = collection.get('airline_10')
149 print(f'Document value: {res.content_as[dict]}')
150
151
152 Simple get operation with options::
153
154 from datetime import timedelta
155 from couchbase.options import GetOptions
156
157 # ... other code ...
158
159 res = collection.get('airline_10', GetOptions(timeout=timedelta(seconds=2)))
160 print(f'Document value: {res.content_as[dict]}')
161
162 """
163 instruments = self._impl.observability_instruments
164 with ObservableRequestHandler.create(KeyValueOperationType.Get, instruments) as obs_handler:
165 req, transcoder = self._impl.request_builder.build_get_request(key, obs_handler, *opts, **kwargs)
166 return self._impl.get(req, transcoder, obs_handler)
167
168 def get_any_replica(self,
169 key, # type: str

Callers 15

set_removeMethod · 0.95
set_containsMethod · 0.95
create_cmake_configMethod · 0.45
runMethod · 0.45
get_decode_formatFunction · 0.45
idMethod · 0.45
localMethod · 0.45
remoteMethod · 0.45
namespaceMethod · 0.45
last_activityMethod · 0.45
last_activity_usMethod · 0.45

Calls 2

build_get_requestMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected