0

I'm trying to make a trully simple query with Emberfire, but it's not working. No console errors, it just doesn't do a thing.
My versions are Ember 2.2.0, Ember-data 2.2.0 and EmberFire 1.6.1
My data is something like the folowing:

{
  'data':[{
   'element' : 0 
  },{
   'element' : 1 
  },{
   'element' : 1 
  },{
   'element' : 0 
  },{
   'element' : 2 
  }]
}

And my query in Ember would be something like this:

export default Ember.Route.extend({
  model(){
    return this.store.query('data', { orderBy: 'element', equalTo: 1 } );
  }
});

The results, passing trough an each loop, are looking like this

0 0 1 1 2

Only works the orderBy part, not the equalsTo. Any suggestions?

Lowlo
  • 255
  • 1
  • 16
  • I found that question [link](http://stackoverflow.com/questions/27877612/firebase-no-index-defined) that solves part of my problem. Now I don't fall on Firebase warning adding the needed security rule. Now comes the funny part. As I can see, if I try to query with equalTo : 0, it returns all the available positions. Maybe it's parsing the query as a false, trying to do an exact match with false, and then everything is not exactly false, so... everything matches. If the desired search is other value it works fine. Any clue? (more htan adding an empty position at the begining :D) – Lowlo Nov 27 '15 at 12:55
  • What if u parsed it to a string :D ? – kristjan reinhold Nov 27 '15 at 13:59
  • Let me go away backwards, getting into a bush like Homer, please. Lot of thanks. Anyway, it's a little bit ankward to "stringify" numbers just for that... – Lowlo Nov 27 '15 at 18:54
  • Well it does seem like it parses it as false. "ankward" – kristjan reinhold Nov 27 '15 at 19:45
  • @LowloDesign I emailed the [Firebase + Ember] google group and they let me know this is a bug. I was trying to pass `false` but looking at the code `0` would be treated the same way: "Looks like you found a bug! We are not correctly detecting when you pass `false`. https://github.com/firebase/emberfire/blob/5858d4ce9f533d5faa1f86f53a1271d1be077b59/addon/adapters/firebase.js#L315-L317 I will get this sorted ASAP." – Aaron Jan 21 '16 at 19:04
  • Thanks for asking them @Aaron ! Finally I overcame the problem modifying the model, turning day data type from number to string. But I'm still thinking it's a nonsense, and they told you it's a bug, so I wasn't too away... Ping me back if they update you. – Lowlo Jan 22 '16 at 10:04

1 Answers1

0

There is an Ember addon for querying a firebase search.

You can check it out here:

https://www.npmjs.com/package/ember-emberfire-find-query

Tom
  • 350
  • 4
  • 21