Start a new topic

Ember.js - Querying Dates

With ember-data, the models I'm using are just being passed Javascript Date Objects:

App.Log = Kinvey.Model.extend({

date: DS.attr('date'),

});



How do I query these dates? This doesn't seem to work:

var query = new Kinvey.Query();

query.greaterThanOrEqualTo('date', moment().subtract(7, 'days').toDate().toString() );

this.store.find('log',query);



When I pass a javascript date object in, I just get an error and the page won't load. If I pass in a string, it doesn't seem to recognize the text as a date.


`toString()` on the `Date` object will not return the right format used for comparing dates. Try `toISOString()` instead:



```

query.greaterThanOrEqualTo('date', moment().subtract(7, 'days').toDate().toISOString());

```
The problem is that the Kinvey Ember.js Model REST Adapter doesn't store the dates in ISO format, they store them in the toString format. Are you guys planning on fixing this in the REST adapter?
I see the problem now. Yes, this will be fixed in the REST adapter.
Login or Signup to post a comment