Why does this Firebase “.indexOn” not work?

前端 未结 1 1113
灰色年华
灰色年华 2020-12-11 03:56

So I have data like so:

pushNotifications {
    -K - RwEgd541PIGNOXXUH: {
        message: \"Xiaoyu Hugh Hou bid at $900 on your task: New P...\"
        no         


        
相关标签:
1条回答
  • 2020-12-11 04:38

    You need to put the .indexOn one level higher than what you did:

     "pushNotifications": {
        ".read": "auth != null",
        ".write": "auth != null",
        ".indexOn": ["notifyId", "timestamp"]
    },
    

    For comparison always look at the Firebase documentation on indexes, which uses this JSON example:

    "dinosaurs": {
      "lambeosaurus": {
        "height" : 2.1,
        "length" : 12.5,
        "weight": 5000
      },
      "stegosaurus": {
        "height" : 4,
        "length" : 9,
        "weight" : 2500
      }
    }
    

    With this indexing rule:

    {
      "rules": {
        "dinosaurs": {
          ".indexOn": ["height", "length"]
        }
      }
    }
    
    0 讨论(0)
提交回复
热议问题