Reputation: 39
Can I create request to table 'User' for filter by value one field, I don't want get all record in table 'user'. For example: I have array.
[{email: "[email protected]", password: "111"}, {email: "[email protected]", password: "111"}]
I created request:
af: AngularFire;
this.af.database.object('/users/',{
query: {
orderByChild: 'password',
equalTo: '14714711'
}
})
This request get my 2 record. if want get 1 record. What my create request with filter by value 1 field?
Upvotes: 1
Views: 85
Reputation: 598797
To limit to a single result, add limitToFirst: 1
to your query:
this.af.database.object('/users/',{
query: {
orderByChild: 'password',
equalTo: '14714711',
limitToFirst: 1
}
})
Since you're executing a query, you'll still get a list as a result. When you execute a query against the Firebase Database, there will potentially be multiple results. So the snapshot contains a list of those results. Even if there is only a single result, the snapshot will contain a list of one result.
Upvotes: 2