Bart Koppelmans
Bart Koppelmans

Reputation: 55

Can't filter Firebase data

I'm having problems filtering the data with the element of polymer. My code is like this:

<firebase-collection location="--url--" order-by-child="user_id" equal-to="1" log="true"  data="{{message}}"></firebase-collection>

My database is:

messages 
 |
 |__0__content
 |  |__letter_id
 |  |__user_id
 |  |__datetime
 |
 |__1__content
 |  |__letter_id
 |  |__user_id
 |  |__datetime
 |
 |__etcetera

This should get the messages with a user_id that is equal to 1. However, this shows nothing. I guess this is a problem with my syntax, but I can't figure out the problem.

Upvotes: 0

Views: 434

Answers (2)

Sean
Sean

Reputation: 2529

I had the same issue but fixed it by using both the orderByValueType (as number) and the orderByChild set like so:

  <firebase-collection
       order-by-child="posted_date"
       start-at="0"
       order-value-type="number"
       limit-to-first="1"
       log="true"
       location="https://somefirebaselocation.firebaseio.com/articles"
       data="{{articles}}"></firebase-collection>

Without the order-value-type the query did not work.

Upvotes: 1

Bart Koppelmans
Bart Koppelmans

Reputation: 55

Never mind, I had my Firebase database setup with user_id set as a number. Therefore it could not obtain fetch the data.

Upvotes: 1

Related Questions