Firestore索引和查询返回空结果

时间:2018-04-28 05:18:13

标签: firebase google-cloud-firestore angularfire2

数据=>类别集合

[
  {
    "category": "toys and games",
    "factory": 1,
    "link": "action-figure-toys-",
    "name": "action figure toys",
    "type": "subcategory"
  },
  {
    "category": "toys and games",
    "factory": 1,
    "link": "action-figure-toys1",
    "name": "action figure toys1",
    "type": "subcategory"
  },
  {
    "category": "",
    "factory": 1,
    "link": "action-figure-toys-",
    "name": "toys and games",
    "type": "category"
  },

]

索引

{
  "collectionId": "categories",
  "fields": [
    { "fieldPath": "name", "mode": "ASCENDING" },
    { "fieldPath": "type", "mode": "ASCENDING" },
    { "fieldPath": "factory", "mode": "ASCENDING" },
    { "fieldPath": "category", "mode": "ASCENDING" },
    { "fieldPath": "subCategory", "mode": "ASCENDING" }
  ]
}

查询

this.db
      .collection('categories', ref =>
        ref
          .where('type', '==', 'category')
          .where('factory', '==', 1)
          .orderBy('name')
          .startAt(this.selected)
          .limit(5)
      ).valueChanges();

查询总是返回空结果,如果我评论where子句的工作方式! 如果它只有where子句返回。 where和startAt的组合导致问题

0 个答案:

没有答案