simplajs / simpla

Open, modular, and serverless content management for a modern web
https://www.simplajs.org
MIT License
527 stars 36 forks source link

Set should patch content in the buffer #61

Closed bedeoverend closed 7 years ago

bedeoverend commented 7 years ago

This changes the behaviour of set to overwrite what's currently in the buffer, rather than overwriting it. This means doing the following:

Simpla.set('/title', {
  type: 'Text',
  data: { text: 'Hello World' },
});

// Some time later....
Simpla.set('/title', {
  data: { text: 'Hi there' },
});

Simpla.get('/title').then(response => console.log(response));

would log:

{
  type: 'Text',
  data: { text: 'Hi there' },
}

i.e. the type was retained from the first set.

This particularly means that the createdAt and updatedAt properties set by the API on save won't be lost on subsequent local sets.