我的客户数据库是这样的:
{
"customers": {
"9115625853": {
"address": "16-37-4/3, Innespeta, Rajahmundry 533101",
"adhaar": "1111-2222-3333",
"currentPackage": {
"activation": "2016-11-22",
"dataConsumed": 5905580032,
"dataTotal": 21474836480,
"expiry": "2016-12-22",
"packageName": "5MB-20GB",
"speedDown": "5 Mbps",
"speedUp": "5 Mbps"
},
"email": "sureshk@gmail.com",
"mobileno": "9115625853",
"name": "Suresh Kumar P",
"registered": "2016-11-22"
},
"7032906292": {
"address": "46-17-24, Danavaipeta, Rajahmundry 533103",
"adhaar": "5555-2342-3633",
"currentPackage": {
"activation": "2016-11-12",
"dataConsumed": 18253611008,
"dataTotal": 21474836480,
"expiry": "2016-12-12",
"packageName": "5MB-20GB",
"speedDown": "5 Mbps",
"speedUp": "5 Mbps"
},
"email": "lakshman@laurel.solutions",
"mobileno": "7032906292",
"name": "Lakshman Rao Pilaka",
"registered": "2016-11-12"
},
"9165263347": {
"address": "722 Junius Street, Grazierville, Indiana, 7463",
"adhaar": "3935-1768-7293",
"email": "mannray@biospan.com",
"name": "Mann Ray",
"phone": 9165263347,
"registered": "2016-09-04"
}
}
}
我希望在将子项添加到未应用currentPackage
的客户数据库(即添加9165263347 - Mann Ray
之类的客户)时触发事件。
我写了这样的代码
firebase.database().ref('customers/')
.orderByChild('currentPackage')
.equalTo(null)
.once('child_added')
.then(function(snapshot) {
// My Code
});
我收到错误
未捕获(在承诺中)错误:没有为currentPackage定义索引(...)
我的Firebase规则如下
{
"rules": {
".read": true,
".write": true,
"packages": {
".indexOn": "active"
},
"customers": {
".indexOn": "currentPackage"
}
}
}
我确信,规则定义中有错误,但不知怎的,我无法克服它。
请帮忙。
感谢。