【发布时间】:2017-01-25 15:29:31
【问题描述】:
'child_added' 工作正常,但 'child_removed' 不起作用。
数据索引为 ".indexOn": "status"。
-
Firebase 数据
{ "user uid" : { "-Kb8FSBMOvcposJ-iJYL" : { "createDate" : 1485140252291, "message" : "login", "response" : "none", "status" : "0", "title" : "8. sign-in" }, "-KbL6d1xrfqCBAcP7_Qu" : { "createDate" : 1485356045006, "message" : "logout", "response" : "none", "status" : "1", "title" : "sign-out" } } } -
Firebase 事件监听器
var notiRef = firebase.database().ref('message/' + user.uid); notiRef.orderByChild('status').equalTo('wait').on('child_added', function(snapshot) { //do something... }); notiRef.orderByChild('status').equalTo('wait').on('child_moved', function(snapshot) { // not worked. }); firebase.database().ref('notification/' + user.uid + '/uid').on('child_moved', function(snapshot) { // not worked. }); notiRef.on('child_moved', function(snapshot) { // not worked. });
以上代码中的所有三个 'child_removed' 都不起作用。 设置 ref 目标有问题吗?还是设置 indexOn 有问题? (需要设置 indexOn)
【问题讨论】:
标签: javascript firebase firebase-realtime-database