1

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.