Update Model "get more" with JS

  • 1
  • Problem
  • Updated 3 years ago
  • Not a Problem
Hi,

While writing a snippet where I have to query a model with loads of records in it (800+) I felt the urge to use model.sync() instead of model.updateData() because of the load time. As far as I can tell model.sync() is basically the "get more" version of the multiple actions. 

I know model.sync() is a prototype method and not documented by any means.
Although there is a bug in it and I really would like to have it as an official function :)

Concerning the bug:
When using the regular updateData() function the sort-order of the model gets applied but not when using model.sync(). Instead of appending the data it prepends all the newly queried data (I sorted by CreatedDate).
To be extra sure I queried the model using the action framework and the option "get more", which worked correctly (it appended the new data as it should).

I stumbled across this little issue while reading/importing data from IOT-Devices once every minute and then live-updating charts (which are categorized by CreatedDate. I wouldn't have noticed it otherwise).

For now I implemented the workaround using multiple actions to "get more" data but I hope that the model.sync() will soon be an official function :)

Cheers
Photo of David Giger

David Giger

  • 1,758 Points 1k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
model.getMoreData() is the "get more" version. Use that instead. model.sync() is not supported yet.
Photo of David Giger

David Giger

  • 1,758 Points 1k badge 2x thumb
Cool, thanks Zach!