在Firebase中创建一个空的子记录 [英] Create an empty child record in Firebase

查看:117
本文介绍了在Firebase中创建一个空的子记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Firebase数据视图创建一个孩子,但是看起来这是不可能的,因为创建节点会直接消失或者无法随时显示。
我试图离开价值领域空,但是这根本不工作,以及写入null值的字段。
我是否做错了?

-Fabian

解决方案

空值和空值与不存在的记录相同。如果你想要它存在,你必须设置一个值。

换句话说,当你测试一个记录的存在,你是不是看看是否键是在数据库中,您正在查看路径(该键的位置)是否有任何数据。



建议:使用falsy值,如0或false直到你有一些数据扔到那个位置。你不像数据类型那样受数据类型的限制,所以你可以随时用object / array /等替换它。


I am trying to create a child using the Firebase data view but it seems that this is not possible as the create node directly disappears or rather doesn't show up at any time. I tried to leave the value field empty but this doesn't work at all as well as writing null into the value field. Am I doing it wrong?

-Fabian

解决方案

Null and empty values are the same as the record not existing. If you want it to exist, you have to set a value.

In other words, when you test for a record's existence, you aren't looking to see if the key is in the database, you are looking to see if the path (the location of that key) has any data.

Suggestion: use a falsy value like 0 or false until you have some data to throw into that location. You're not limited by data types as you would be with SQL, so you can always replace that with an object/array/et al later.

这篇关于在Firebase中创建一个空的子记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆