I want to implement search by email in my app but kinda stuck with the design of query. my data structure looks like this
users {
uid {
email: [email protected]
i tried the following query:
console.log(reqestEmail); // proper email here
new Firebase(USERS)
.startAt(reqestEmail)
.endAt(reqestEmail)
.once('value', function(snap){
var foundUser = snap.val();
console.log(foundUser) // output is null
});
I guess the problem is in the fact i have a uid in the path. But how to to implement search with this data structure — if i this uid is the needed result?
If it is important using Firebase 2.0.2 and AngularFire 0.9
Sorry guys: noob here. Also in danger of suspention of account.
You have to first order by email address, so that you can then filter on it:
console.log(reqestEmail); // proper email here
new Firebase(USERS)
.orderByChild('email')
.startAt(reqestEmail)
.endAt(reqestEmail)
.once('value', function(snap){
var foundUser = snap.val();
console.log(foundUser) // output is correct now
});
Working sample in this jsbin: http://jsbin.com/fenavu/2/edit?js,console
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