Today I started experimenting with Firebase Live database. Maybe I'm thinking too much in sql terms. But what I want to do is get a record from my database where a value equals a variable with flutter. My table looks like this:
What I'm trying to achieve is something like this:
FirebaseDatabase.instance.reference().child('users').where('User_id', 1508)
Like I said. I'm a complete beginner when it comes to Live Databases. I hope someone can help me with this issue I'm having.
Kind regards, Namanix
You will need to add the list of query options that a user will search for. At the time when you are pushing data into the firestore you can do is to create the search query options. This will result in pushing all the queries that a user can search for.
According to firstore docs
Firestore.instance
.collection('talks')
.where("topic", isEqualTo: "flutter")
.snapshots()
.listen((data) =>
data.documents.forEach((doc) => print(doc["title"])));
If you have the user id in a variable for example called:
String uid = currentUser.uid;
then you can do the following:
FirebaseDatabase.instance.reference().child('users/$uid')
Update I think this is what you are asking about
FirebaseDatabase.instance
.reference().child("users")
.orderByChild("User_id")
.equalTo($this.userId)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With