Reputation: 632
I'm using firebase real time database with react native. Here I'm trying to login the user based on email address.
firebase.database().ref('Users')
.startAt(email)
.endAt(email)
.once('value', function (snap) {
console.log(snap)
console.log('accounts matching email address', snap.val())
});
I have number of documents inside the Users
collection. I'm trying to fetch the document which contains the email address I'm passing inside email
variable. But in the console I'm getting the value as null.
accounts matching email address, null
I'm giving proper email address in the variable. Any ideas?
Upvotes: 0
Views: 150
Reputation: 80914
You should use equalTo()
to query according to the email address:
firebase.database().ref('Users')
.orderByChild("email")
.equalTo(email)
.once('value', function (snap) {
console.log(snap)
console.log('accounts matching email address', snap.val())
});
Assuming you have the following db:
Users
randomId
email : email_here
Upvotes: 1