我想使用nodejs将数据推送到Firebase。
我有一个包含MACID值的字符串,我想检索MACID = macid(存储在firebase中)的密钥。和模型(存储在firebase中)。

据此,我想推送类似的数据
        realdata = {
              温度:“ sasad”,
              湿度:“ 123dsad4”,
              时间戳:“ dfssdsdf”,
                 }

火力基地就像

node.js - 使用子引用值将数据推送到Firebase-LMLPHP

如图所示,每个用户都有许多设备。我想在macid = MACID处推送数据。我只有要比较的MACID。

如何将数据推送到其中macid = MACID的Firebase并将其存储,如图所示。

提前致谢。

最佳答案

如果知道UID,则可以向该用户的设备查询与MACID匹配的设备。

firebase.database().ref("users").child(uid).orderByChild("macid").equalTo(macId)


如果您不知道用户的UID,则无法使用当前数据结构进行查询。您将需要添加将MACID映射到UID的其他列表,例如

"macids": {
  "dasdad": "h1Eg5...."
  "dasasd": "h1Eg5...."
}


另请参阅:


Firebase Query Double Nested
Firebase query if child of child contains a value

07-28 09:52