I was looking at the diagram for a sync operation in Kinto docs and i have a doubt.
Why does .sync() is a pull.then(push).then(pull) instead of just pull.then(push)?
What do we need the last pull for?
I was looking at the diagram for a sync operation in Kinto docs and i have a doubt.
Why does .sync() is a pull.then(push).then(pull) instead of just pull.then(push)?
What do we need the last pull for?
When you do your push you will update the records
last_modifiedvalue, so at the end you will need to grab the newlast_modifiedvalue of the list.You may also have got some changes on the collection while you were pushing your changes (done by another device).
pulling after the push will let you grab the new
last_modifiedvalue, the changes that you've made as well as the changes that were made in the meantime.At this point you might think that grabbing the changes you've made is a bit silly (because you already know what you just pushed). It is basically the subject of this issue.
The idea is that you can also try to pull with the
last_modifiedvalue of your last update as aIf-Matchheader using thelast_modifiedvalue of the collection before your changes as a_sinceparameter and excluding all the records IDs you've changed.In that case you will get a 304 most of the time or a list of changes that were made by others while you were doing your push.