Reputation: 319
I would like to be able to obtain the data that is inside grupofav
, this data is equivalent to grupoid3
, but I cannot access the reference that is equivalent to that value in firebase database real-time, the idea is to be able to pass the id of the favourite group to another reference accessing that particular group.
I tried doing this
var grupoFav = FirebaseDatabase.instance
.ref()
.child("usuarios")
.child("T1gMWDq6d6R6cKSyd8StjKV8drg1")
.child("grupofav")
.get()
.toString();
but with get, onvalue and others, I couldn't get to the data
Upvotes: 0
Views: 2506
Reputation: 600131
get
is an asynchronous operation, so you'll need to await
its result:
var dbRef = FirebaseDatabase.instance
.ref()
.child("usuarios")
.child("T1gMWDq6d6R6cKSyd8StjKV8drg1")
.child("grupofav")
var snapshot = await dbRef.get(); // 👈 Use await here
var grupoFav = snapshot.value; // 👈 Use value here
Upvotes: 1
Reputation: 390
try following
FirebaseDatabase.instance
.ref()
.child("usuarios")
.orderByChild('groupfav')
.get();
Upvotes: 0