I understand it is possible to order by a field in a pointer, in my case I have a date field in a pointer and I would like to order by it using .ascending() I am trying with dot notation as i have read that is the correct usage but still no dice 'eventPointer.startDate' it does not order anything by date
Server
JS SDK
let myEvents = await new Parse.Query(AttendIntent)
.equalTo("userId", user.id)
.include('eventPointer')
.select('eventPointer.startDate')
.ascending('eventPointer.startDate')
.find(masterKey)
Seems to be similar https://github.com/parse-community/Parse-SDK-JS/issues/235
This currently isn't implemented. As a workaround you can do the sorting after you retrieve all the objects.
The reason why is handleInclude
Sorting happens in step 1, you don't have any pointer values until after step 2.
To get what you want working, you would have to add custom sort after step 2 since you now have all included values.
Would you like to open a PR? I know this has been a highly requested feature.
@acinader @davimacedo Thoughts?
A PR regarding this would be very welcome for sure, but not so easy to be done.
In the meantime, you can use aggregation to perform this query.
@REPTILEHAUS Here is an example for sorting pointer values using aggregates.
I also have issue with this one that I resorted to using mongoDB driver to achieve this like what @dplewis mentioned. There's also performance problem when doing manual sorting with pagination.
If you are interested I added a custom sort to the Local Datastore queries.
https://github.com/parse-community/Parse-SDK-JS/blob/master/src/ParseQuery.js#L142
You can use that as a reference to implement this feature. It works with ascending / addAscending multiple sorts. More test cases would be needed but seems solid
I did something similar but struggling with large dataset because where doing it manually rather than with database. That's why I'm bypassing Parse and use aggregate instead in MongoDB Driver.
its now 2020. i do really want this feature.
Most helpful comment
its now 2020. i do really want this feature.