Receive user email from Firebase requesting

I want to implement email search in my application, but am not fixated on query design. my data structure is as follows:

users { uid { email: email@email.com 

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 think the problem is that I have a uid on the way. But how to implement a search with this data structure - if I this uid is a necessary result?

If it is important to use Firebase 2.0.2 and AngularFire 0.9

Sorry guys: noob is here. Also at risk of account retention.

+5
source share
1 answer

You must first order by email so that you can then filter 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 example in this jsbin: http://jsbin.com/fenavu/2/edit?js,console

+7
source

Source: https://habr.com/ru/post/1207698/


All Articles