Sending sorting params to API with can-connect model

I ran into an issue where I was sending sorting params to the API with a getList call:

// API using NeDB
MyModel.getList({'$sort': {dateAdded: 1}}).then(function (resp) {
  vm.attr('myList', resp);

I found that when I create a new item in the list, can-set determines that the new item is not a subset of the main set using the above parameters. can-real-time, therefore, does not update the list with the new item! :frowning:

I am able to workaround this by using can.List.sort plugin. But I’m curious how others are handling sorting, pagination, etc while using can-real-time. Has anyone else tried this out and, if so, how are you passing the parameters to the model without affecting can-real-time?

1 Like

Sorting was being worked on by Alfredo here

Currently, it’s not supported. So the best thing to do is create a set-algebra that ignores the sort property and pass that to your model.

new set.Algebra({
  "$sort" : function(){ return true }