In the documentations for Query.startAt()
and Query.endAt()
, under 'Arguments', you will see that the first argument, value
, is:
The value to start [or end] at. The argument type depends on which orderBy*()
function was used in this query. Specify a value that matches the orderBy*()
type. When used in combination with orderByKey()
, the value must be a string.
The Querying Data section of the Web Guide says,
With Firebase database queries, we can selectively retrieve data based on various factors. To construct a query in your database, you start by specifying how you want your data to be ordered using one of the ordering functions: orderByChild()
, orderByKey()
, orderByValue()
, or orderByPriority()
. You can then combine these with five other methods to conduct complex queries: limitToFirst()
, limitToLast()
, startAt()
, endAt()
, and equalTo()
.
- If the user objects have a priority, and an orderBy is not specified for the
Query
, the query will sort by priorities and startAt/endAt by indices will work. You can use .setPriority()
or .setWithPriority()
.
- If the user objects do not have a priority set, and the
Query
has no orderBy*()
, snapshot.val()
will be null.
For your query, if the user objects do not have priorities set, sorting by the email
child will make startAt
/endAt
work, like so:
new Firebase("https://blazing-fire-2739.firebaseio.com/users")
.orderByChild('email')
.startAt($scope.user.email)
.endAt($scope.user.email)
.once('value', function(snap) {
console.log('accounts matching email address', snap.val())
});
Here is a working plnkr example of this query.
However, as Kato pointed out in the comments,
"As a general recommendation, orderByChild()
supersedes priorities and should be preferred. Priorities will eventually be phased out in favor of child fields."
Since your goal is to locate a single specific user by her email address and since there should be only one user with a given email
child value, you can,
- Order the
Query
object for /users
by the "email"
child key;
- Query for the user object for which the
email
child is equalTo(<email>)
.
For example:
var usersRef = new Firebase("https://blazing-fire-2739.firebaseio.com/users");
userRef.orderByChild("email").equalTo($scope.user.email).once("value", function(snapshot) {
if(snapshot.exists()){
console.log(snapshot.val());
}
});
And here is a working plnkr example of this second query.
For more information, check out the documentation for Query.equalTo()
and Query.orderByChild()
.
Important side-note: when ordering by a child key, if you know what the indices for your query will be, "you can define them via the .indexOn
rule in your Security and Firebase Rules for better performance." Check out the Indexing Data documentation for more info.
It might be helpful to read over the Retrieving Data Guide.
To inspect your Firebase data in the browser and see objects' priorities, you can use Vulcan -- an awesome Google Chrome extension. This is what Vulcan looks like in the Chrome DevTools:

(source: firebase.com)
Hope this helps!