[英]Is it possible to use the REST API "shallow" feature with Firebase data filtering query parameters?
使用 REST 檢索 Firebase 數據的文檔 ( https://firebase.google.com/docs/database/rest/retrieve-data ) 明確指出“shallow 不能與任何“過濾數據”查詢參數一起使用”。 在這里我被告知可以使用過濾器(例如limitToFirst、startAfter)運行淺查詢。
運行這個:
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
databaseReference = db.reference("/")
snapshot = databaseReference.child("Bot Applications").order_by_child("status").equal_to("ACTIVE").limit_to_first(self.applicationKeyCollectionCount).get(etag=False, shallow=True)
或者
snapshot = databaseReference.child("Bot Applications").order_by_key().limit_to_first(self.applicationKeyCollectionCount).get(etag=False, shallow=True)
或此查詢的任何其他簡化變體都會導致錯誤消息,例如
AttributeError: 'Query' object has no attribute 'shallow'
或者
TypeError: get() got an unexpected keyword argument 'shallow'
或者
TypeError: get() got an unexpected keyword argument 'etag'
當查詢刪除所有過濾器時,代碼成功運行,例如
snapshot = databaseReference.child("Bot Applications").get(etag=False, shallow=True)
或者沒有像
snapshot = databaseReference.child("Bot Applications").order_by_child("status").equal_to("ACTIVE").limit_to_first(self.applicationKeyCollectionCount).get()
有沒有一種有效的方法來以某種方式運行帶有過濾器的淺 FRTDB 查詢?
據我所知,REST API 可以過濾它返回的數據。 所以如果你請求一個淺的結果集,它只能過濾鍵。 這也正是我在您鏈接的答案中的示例中所做的。
沒有辦法進行淺查詢,然后對返回的鍵下的任何屬性進行過濾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.