Firebase数据库规则,获取数据的问题
Firebase Database RULES, problems in getting data
- thatguy 问题:
- 大家好,我对Firebase数据库规则有一些问题。我把这段代码放在我的规则部分:
{ "rules": { "pizzerie": { "$casualWord" : { ".read" : true, ".write": true } } }}
- 我有一个这样结构的数据库:
{ "pizzerie" : { "pizzeriaDaLuigi" : { "Info" : { "apertiPranzo" : false, "apertoLunedi" : true, "apertoMartedi" : false, "colore" : "#38dce0", "indirizzo" : "Caserta", "indirizzoCompleto" : "Via Giacomo Puccini, Macerata Campania, 81047, Caserta", "nome" : "I Masanielli", "senzaGlutine" : true, "spazioEsterno" : true, "telefono" : "3202777037" }, "Prenotazioni" : { "pizzeriaDaLuigi001" : { "anno" : 2018, "giorno" : 21, "mese" : 5, "minuto" : 30, "ora" : 21, "persone" : 8 } }}
- 我正在使用以下javascript代码访问这些信息:
database.ref('pizzerie').once("value", function(snapshot) { snapshot.forEach(function(child) { console.log(child.child('Info/colore').val());});}
- 但是什么也没有归还,为什么
- 回答:
- Renaud Tarnec - vote: 0
- 这应该有效:
- 查询:
database.ref('pizzerie').once("value", function(snapshot) { snapshot.forEach(function(child) { var childData = child.val(); console.log(childData.Info.colore); });})
- 规则:
{ "rules": { "pizzerie": { ".read" : true, ".write": true } }}
- Renaud Tarnec - vote: 0