mckoss / pageforest

Automatically exported from code.google.com/p/pageforest
0 stars 0 forks source link

[channel] Need to distinguish between create and update #75

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, the only hint one get is from the event.method. In the current 
implementation, there is no easy way to distinguish between create and update.

storage.subscribe(username, undefined, {children: true}, updateChannel);
var updateChannel = function(event) {
  switch(event.method) {
    case 'POST':
    case 'PUSH':
    case 'PUT':
  }
}

Original issue reported on code.google.com by thomasl...@gmail.com on 25 Jan 2011 at 12:29

GoogleCodeExporter commented 9 years ago
Since PUT can be used to create a resource, I think I need a new field here.  I 
think what I will do is include the 'If-Match' parameter.  It takes on values 
of:

'new' - Must be creating a new resource.
'overwrite' - Can be a create or an update.
'<sha1-hash>' - Must match the previous sha1 hash in order to update the entity.

(see http://stackoverflow.com/questions/630453/put-vs-post-in-rest)

Original comment by mckoss@gmail.com on 28 Jan 2011 at 11:19