2017-09-04 65 views
0

如何寫.indexOn火力地堡和Android的代碼示例
(問題 - > PushId - >喜歡 - > UserUID)如何書寫.indexOn?

{ 
"Question" : { 
    "-Kt6vXlTii19eBkKa4Wr" : { 
    "Likes" : { 
     "bEYW6usk5rNo5WT1tdkiBZIv1TN2" : true, 
     "20Wioh8McfOeZWnn3dfVsRlQ25M2" : true 
    }, 
    "answer_count" : 0, 
    "description" : "ds", 
    "image" : "aa", 
    "sender_uid" : "bEYW6usk5rNo5WT1tdkiBZIv1TN2", 
    "time" : 1504445344214 
    } 
}, 
"Users" : { 
    "20Wioh8McfOeZWnn3dfVsRlQ25M2" : { 
    "image" : "image", 
    "mail" : "mail", 
    "name" : "image" 
    }, 
    "bEYW6usk5rNo5WT1tdkiBZIv1TN2" : { 
    "image" : "image", 
    "mail" : "mail", 
    "name" : "image" 
    } 
} 
} 

這是我的規則,但不能正常工作

{ 
    "rules": { 
     "Question": { 
      ".read": "auth != null", 
      ".write": "auth != null", 
      ".indexOn": ["sender_uid","Likes"], 
     }, 
     "Users": { 
     ".read": "auth != null", 
     "$uid": { 
      ".write": "$uid === auth.uid", 

     } 
     } 
    } 
    } 
+0

請具體說明什麼是不工作。 –

+0

我不知道錯誤的結果總是爲空 – Ekrem

+0

從標題中刪除標籤;佈局。 – Cerbrus

回答

0

這是解決方案

{ 
"rules": { 
    "Question": { 
     ".read": "auth != null", 
     ".write": "auth != null", 
     ".indexOn": ["sender_uid","Likes/value"], 

     } 
    , 
    "Users": { 
    ".read": "auth != null", 
    "$uid": { 
     ".write": "$uid === auth.uid", 

    } 
    } 
} 

}