@@ -125,26 +125,33 @@ def child(self, path):
125125 full_path = self ._pathurl + '/' + path
126126 return Reference (client = self ._client , path = full_path )
127127
128- def get (self , etag = False ):
128+ def get (self , etag = False , shallow = False ):
129129 """Returns the value, and optionally the ETag, at the current location of the database.
130130
131131 Args:
132132 etag: A boolean indicating whether the Etag value should be returned or not (optional).
133+ shallow: A boolean indicating whether to execute a shallow read (optional). Shallow
134+ reads do not retrieve the child nodes of the current database location. Cannot be
135+ set to True if ``etag`` is also set to True.
133136
134137 Returns:
135138 object: If etag is False returns the decoded JSON value of the current database location.
136139 If etag is True, returns a 2-tuple consisting of the decoded JSON value and the Etag
137140 associated with the current database location.
138141
139142 Raises:
143+ ValueError: If both ``etag`` and ``shallow`` are set to True.
140144 ApiCallError: If an error occurs while communicating with the remote database server.
141145 """
142146 if etag :
147+ if shallow :
148+ raise ValueError ('etag and shallow cannot both be set to True.' )
143149 headers , data = self ._client .headers_and_body (
144150 'get' , self ._add_suffix (), headers = {'X-Firebase-ETag' : 'true' })
145151 return data , headers .get ('ETag' )
146152 else :
147- return self ._client .body ('get' , self ._add_suffix ())
153+ params = 'shallow=true' if shallow else None
154+ return self ._client .body ('get' , self ._add_suffix (), params = params )
148155
149156 def get_if_changed (self , etag ):
150157 """Gets data in this location only if the specified ETag does not match.
0 commit comments