Skip to content

Commit

Permalink
implementing FieldFilter for categories endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
maceto committed Jul 23, 2024
1 parent a31443f commit 7f12b2c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions functions/categories/libs/queries.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import os
import json
from google.cloud import firestore
from google.cloud.firestore_v1.base_query import FieldFilter
from .result import Result
from .utils import convert_to_array

DB = firestore.Client(project=os.environ.get('PROJECT'), database=os.environ.get('DATABASE'))
TABLE = 'categories'

def list_data(params):
ref = DB.collection(u'categories')
ref = DB.collection(TABLE)

query = ref

Expand All @@ -27,7 +28,7 @@ def list_data(params):
category_array = convert_to_array(params['category'])

for category in category_array:
results = query.where("category", "==", category).stream()
results = query.where(filter=FieldFilter("category", "==", category)).stream()
for doc in results:
data.append(doc.to_dict())

Expand Down

0 comments on commit 7f12b2c

Please sign in to comment.