1

I am trying to get data from firebase with value of user's username. I've tried 2 different method a week ago, but now I'm back at it, I noticed I've deleted it.

Here inside home.ts where I subscribe the data

this.database.list<EventModels>('event-list').valueChanges().subscribe((eventData) => { 

}, (err)=>{
 console.log("Error while retrieving event details : ", err);
}); 

this.eventListRef$ = this.database.list<EventModels>('event-list');
this.eventList$ = this.eventListRef$.snapshotChanges()
.pipe(
  map(changes => 
    changes.map(c => ({ id: c.payload.key, ...c.payload.val() }))
  )
);

The data I want to filter is equal to creator

enter image description here

Since I set creator to user's email, I want to list all event that was created by the user only, by using == firebase.auth().currentUser.email and all the one that I've tried failed.

1 Answer 1

2

From the AngularFire documentation on querying lists:

db.list('/items', ref => ref.orderByChild('size').equalTo('large'))

So it looks like yours should be something like:

this.eventListRef$ = this.database.list<EventModels>('event-list', 
  ref => firebase.database().ref("event-list").orderByChild("email").equalTo(firebase.auth().currentUser.email));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.