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_modified
value, so at the end you will need to grab the newlast_modified
value 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_modified
value, 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_modified
value of your last update as aIf-Match
header using thelast_modified
value of the collection before your changes as a_since
parameter 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.