如何在Firestore REST API runQuery中对CompositeFilter使用“ OR”操作

时间:2018-08-28 09:36:59

标签: firebase google-cloud-firestore

我正在研究Firestore REST API runQuery

我想获取所有符合此条件的文档:

college == 'CUHK' OR college == 'HKU'

我在复合滤镜的操作中正在寻找"OR",不幸的是它不存在 (Firestore Official Documentation)

下面的查询还有其他选择吗? (我想要但不存在的东西)

{
 "structuredQuery": {
  "from": [
   {
    "collectionId": "participants"
   }
  ],
  "where": {
   "compositeFilter": {
    "op": "OR", // <- what I want
    "filters": [
     {
      "fieldFilter": {
       "field": {
        "fieldPath": "college"
       },
       "op": "EQUAL",
       "value": {
        "stringValue": "CUHK"
       }
      }
     }, // OR
     {
      "fieldFilter": {
       "field": {
        "fieldPath": "college"
       },
       "op": "EQUAL",
       "value": {
        "stringValue": "HKU"
       }
      }
     }
    ]
   }
  }
 }
}

0 个答案:

没有答案