GetReference () and getChild ()

I was wondering what is the difference between database.getReference("foo/bar/123") and database.getReference("foo").child("bar").child("123") ?

I assume the later one will load the full object "foo", whereas database.getReference("foo/bar/123") just loads the object "123"?

Is my guess correct or what is the correct / most efficient way to load 123 data?

+7
android firebase firebase-database
source share
2 answers

These two are equivalent. You can verify this manually by printing toString () for both links.

Links are cheap - there is nothing ineffective in any of the solutions. None of them have uploaded any data yet. A link is just a pointer to a location in the database.

+2
source share

This should not change, the link is not executed when creating the instance. This is the most important document I can find,

https://firebase.google.com/docs/reference/node/firebase.database.Reference

Documents don't talk about this explicitly, but requests are only executed using .set () or .on () methods

+1
source share

All Articles