Issue
This Content is from Stack Overflow. Question asked by rykamol
Below is the structure of the data. Now how can get the list of data where the uid is equal to ZeN7PcvLeDS8ISjXmBKelk9OUbu2.
I am using Angular 14 and firebase real time database. Following the official doc https://firebase.google.com/docs/database/web/lists-of-data (for crud)
I was trying to achieve this in this way. Any kind of help is highly appreciated. Also above structure of the data is correct according to the types of data?
getall() {
let uid = this.auth.currentUser()?.uid;
const db = getDatabase();
return query(ref(db, 'expenses/' + uid), orderByChild('uid')); }
Solution
To get the expenses of a specific UID, you can do:
query(
ref(db, 'expenses'),
orderByChild('uid'),
equalTo('ZeN7PcvLeDS8ISjXmBKelk9OUbu2')
)
So if uid
has the correct value in your code, that’d be:
query(
ref(db, 'expenses'),
orderByChild('uid'),
equalTo(uid)
)
This Question was asked in StackOverflow by rykamol and Answered by Frank van Puffelen It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.