From 7e4caaf21566db10d05360e39d6eda65dd882fe1 Mon Sep 17 00:00:00 2001 From: Lefteris Tsagkaris Date: Thu, 26 Nov 2020 03:38:36 +0200 Subject: [PATCH] Add start_at/end_at filter by both value and key --- firebase_admin/db.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/firebase_admin/db.py b/firebase_admin/db.py index be2b9c917..26250ba4c 100644 --- a/firebase_admin/db.py +++ b/firebase_admin/db.py @@ -542,7 +542,7 @@ def limit_to_last(self, limit): self._params['limitToLast'] = limit return self - def start_at(self, start): + def start_at(self, start, key=None): """Sets the lower bound for a range query. The Query will only return child nodes with a value greater than or equal to the specified @@ -550,7 +550,7 @@ def start_at(self, start): Args: start: JSON-serializable value to start at, inclusive. - + key: JSON-serializable object key to start at. Returns: Query: The updated Query instance. @@ -559,10 +559,14 @@ def start_at(self, start): """ if start is None: raise ValueError('Start value must not be None.') - self._params['startAt'] = json.dumps(start) + + if key != None: + self._params['startAt'] = json.dumps(start) + ',"' + key + '"' + else: + self._params['startAt'] = json.dumps(start) return self - def end_at(self, end): + def end_at(self, end, key=None): """Sets the upper bound for a range query. The Query will only return child nodes with a value less than or equal to the specified @@ -570,7 +574,7 @@ def end_at(self, end): Args: end: JSON-serializable value to end at, inclusive. - + key: JSON-serializable object key to end at. Returns: Query: The updated Query instance. @@ -579,7 +583,10 @@ def end_at(self, end): """ if end is None: raise ValueError('End value must not be None.') - self._params['endAt'] = json.dumps(end) + if key != None: + self._params['endAt'] = json.dumps(start) + ',"' + key + '"' + else: + self._params['endAt'] = json.dumps(start) return self def equal_to(self, value):