{"action":"reopened","issue":{"url":"https://api.github.com/repos/dscape/nano/issues/281","labels_url":"https://api.github.com/repos/dscape/nano/issues/281/labels{/name}","comments_url":"https://api.github.com/repos/dscape/nano/issues/281/comments","events_url":"https://api.github.com/repos/dscape/nano/issues/281/events","html_url":"https://github.com/dscape/nano/issues/281","id":85668129,"number":281,"title":"DB.insert:  Can not insert extra headers like If-Match:rev to handle 'Document update conflict'","user":{"login":"cloidjgreen","id":3143805,"avatar_url":"https://avatars.githubusercontent.com/u/3143805?v=3","gravatar_id":"","url":"https://api.github.com/users/cloidjgreen","html_url":"https://github.com/cloidjgreen","followers_url":"https://api.github.com/users/cloidjgreen/followers","following_url":"https://api.github.com/users/cloidjgreen/following{/other_user}","gists_url":"https://api.github.com/users/cloidjgreen/gists{/gist_id}","starred_url":"https://api.github.com/users/cloidjgreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloidjgreen/subscriptions","organizations_url":"https://api.github.com/users/cloidjgreen/orgs","repos_url":"https://api.github.com/users/cloidjgreen/repos","events_url":"https://api.github.com/users/cloidjgreen/events{/privacy}","received_events_url":"https://api.github.com/users/cloidjgreen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-06T01:02:46Z","updated_at":"2015-06-29T14:01:00Z","closed_at":null,"body":"This might be just pure ignorance but in attempting to set up CRUD from Angular through Express/nano to CouchDB I of course ran into the need to handle 'Document update conflict'.\r\n\r\nThere seemed to be no path to resolve the problem through DB.insert.  The second parameter accepting only docName at line 372 of nano before assigning the object passed in to qs.  I had set up the insert call with DB.insert(req.body,{docNname:'name',headers{'If-Match':'rev#'}},cb(){});\r\n\r\nFollowing the pass off of the insertDoc function in nano to the relax function I found that the code danced all around opts and qs and never included qs.headers into the request header.\r\n\r\nSo on line 111 of nano I changed \r\n req.headers = _.extend(req.headers, opts.headers, cfg.defaultHeaders);\r\nto \r\nreq.headers = _.extend(req.headers, opts.headers, qs.headers, cfg.defaultHeaders);\r\n\r\nNow after failing on a DB.insert with a 'Document update conflict' I can get the current doc rev, add the headers object with and appropriate \"If-Match\" to the PARAMS, second argument to insert, and force the update.\r\n\r\nComments??\r\n"}}