Firebase - What is the difference between ref and child?

前端 未结 2 1586
忘掉有多难
忘掉有多难 2021-02-01 14:29

In Firebase, ref and child are used a lot.

For example - firebase.database().ref(\'users/\') will work exactly same

相关标签:
2条回答
  • 2021-02-01 15:07

    There is no difference between the two ways you wrote. The only thing is that the first one is a shorthand, where "/" kinda means "child". By the way, the title question you put is not what your question is actually about. "Ref" and "child" are completely different things, because "ref" just makes a reference indicating where the data should go and "child" is specifying the more exact location of that traveling data. I would recommend to change that.

    0 讨论(0)
  • 2021-02-01 15:20

    There is no difference, in any case you have a DatabaseReference instance.

    A Firebase reference represents a particular location in your Database and can be used for reading or writing data to that Database location.

    The method:

    public DatabaseReference getReference (String path)
    

    Gets a DatabaseReference for the provided path.

    The method:

    public DatabaseReference child (String pathString)
    

    Get a reference to location relative to this one.

    0 讨论(0)
提交回复
热议问题