Skip to content

#61 add support to shallow param #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions firebase_admin/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ def child(self, path):
full_path = self._pathurl + '/' + path
return Reference(client=self._client, path=full_path)

def get(self, etag=False):
def get(self, etag=False, shallow=False):
"""Returns the value, and optionally the ETag, at the current location of the database.

Args:
etag: A boolean indicating whether the Etag value should be returned or not (optional).
shallow: A boolean indicating whether the result will be shallow or not (optional).

Returns:
object: If etag is False returns the decoded JSON value of the current database location.
Expand All @@ -139,12 +140,15 @@ def get(self, etag=False):
Raises:
ApiCallError: If an error occurs while communicating with the remote database server.
"""
params = {'shallow': shallow} if shallow else None
if etag:
headers, data = self._client.headers_and_body(
'get', self._add_suffix(), headers={'X-Firebase-ETag' : 'true'})
'get', self._add_suffix(), headers={'X-Firebase-ETag' : 'true'},
params=params)
return data, headers.get('ETag')
else:
return self._client.body('get', self._add_suffix())
return self._client.body(
'get', self._add_suffix(), params=params)

def get_if_changed(self, etag):
"""Gets data in this location only if the specified ETag does not match.
Expand Down