{"action":"created","issue":{"url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1730","repository_url":"https://api.github.com/repos/couchbase/sync_gateway","labels_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1730/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1730/comments","events_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1730/events","html_url":"https://github.com/couchbase/sync_gateway/issues/1730","id":152197600,"number":1730,"title":"Add convenience methods to support put, delete doc without rev","user":{"login":"ThomasMatzner","id":11176531,"avatar_url":"https://avatars.githubusercontent.com/u/11176531?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasMatzner","html_url":"https://github.com/ThomasMatzner","followers_url":"https://api.github.com/users/ThomasMatzner/followers","following_url":"https://api.github.com/users/ThomasMatzner/following{/other_user}","gists_url":"https://api.github.com/users/ThomasMatzner/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasMatzner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasMatzner/subscriptions","organizations_url":"https://api.github.com/users/ThomasMatzner/orgs","repos_url":"https://api.github.com/users/ThomasMatzner/repos","events_url":"https://api.github.com/users/ThomasMatzner/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasMatzner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-01T12:48:13Z","updated_at":"2016-05-04T05:25:42Z","closed_at":null,"body":"The documentation of SG's rest API states that, for put and delete, the revision identifier of the requested document has to be submitted, either via the rev parameter or the HTTP header.\r\n\r\nAlthough validating that revision identifier is a valuable feature for some use cases, it isn't needed in all use cases of an update or delete. It puts unnecessary constraints on the application architecture:\r\n\r\n- Either the document that has been previously read from the database, needs to carry the revision id around all the time it is processed. This is not a matter of course. E.g., if the database records get converted to database-unaware POJOs, the revision id will be lost.\r\n\r\n- Or, before updating or deleting, the document will have to be read (again), just to acquire the revision id. This doesn't offer any additional safety and is a performance obstacle.\r\n\r\nSo the demand of a revision id is neither sufficient to enforce something like a locking scheme, nor is it necessary: Locking can and should, if possible, be done on the business process layer, thereby preventing user actions that are in conflict from the very beginning."},"comment":{"url":"https://api.github.com/repos/couchbase/sync_gateway/issues/comments/216748662","html_url":"https://github.com/couchbase/sync_gateway/issues/1730#issuecomment-216748662","issue_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/1730","id":216748662,"user":{"login":"adamcfraser","id":8866453,"avatar_url":"https://avatars.githubusercontent.com/u/8866453?v=3","gravatar_id":"","url":"https://api.github.com/users/adamcfraser","html_url":"https://github.com/adamcfraser","followers_url":"https://api.github.com/users/adamcfraser/followers","following_url":"https://api.github.com/users/adamcfraser/following{/other_user}","gists_url":"https://api.github.com/users/adamcfraser/gists{/gist_id}","starred_url":"https://api.github.com/users/adamcfraser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamcfraser/subscriptions","organizations_url":"https://api.github.com/users/adamcfraser/orgs","repos_url":"https://api.github.com/users/adamcfraser/repos","events_url":"https://api.github.com/users/adamcfraser/events{/privacy}","received_events_url":"https://api.github.com/users/adamcfraser/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T05:25:42Z","updated_at":"2016-05-04T05:25:42Z","body":"There may be some value in a convenience API that acts as a set instead of replace - when an application knows a particular document only has a single author, and that author only updates from a single platform.\r\n\r\nI've got a couple of concerns, though, that make this a relatively low priority enhancement from my perspective:\r\n\r\n - I don't completely agree with the overhead associated with maintaining the rev value on the client.  The _rev property can be managed completely internally with the document (and so be included in a POJO representation), so I'm not convinced of the burden on the application to maintain it.  \r\n - The new convenience API would definitely have more Sync Gateway overhead than the current PUT operation.  As you say, it would need to do a read then write for each document.\r\n - If you're not actually in a single-author setting, this API will eventually lead to data loss, where your server application overwrites a document that's been updated by another client between read and write - even if that's a small window.\r\n "}}