如何在 firebase 观察者路径中使用通配符?

How to use wildcards in a firebase observer path ?

是否可以在 firebase 观察者的路径中使用通配符?

现在我有:

self.ref?.child('root').child('info').observe(
    DataEventType.childChanged, with: { (snapshot) -> Void in

    //do something   

})

有什么方法可以实现类似的东西:

self.ref?.child('root').child('info').child(<wildcard>).child('details').observe(
     DataEventType.childChanged, with: { (snapshot) -> Void in

    //find out what the wildcard is & do something

})

谢谢

无法观察到这样的节点子集。您的选择是:

  1. 观察info的所有子节点,其中childAdded
  2. details 移动到新的顶级节点并在那里观察。

第一个选项适用于您当前的数据结构。但是它会读取比你感兴趣的更多的数据。第二个选项不会下载太多数据,但是你需要改变你的数据结构。