Skip to content

Instantly share code, notes, and snippets.

@therealplato
Created June 4, 2012 16:57
Show Gist options
  • Save therealplato/2869529 to your computer and use it in GitHub Desktop.
Save therealplato/2869529 to your computer and use it in GitHub Desktop.
leading underscore in documents fails nano's validation
nano = require('nano')('http://localhost:5984');
nano.db.create('underscore', function(err){
data = {foo:'bar', _ISNEW:true};
couchdb = nano.use('underscore');
couchdb.insert(data, function(err,body) {
console.log('err:\n'+err+'\nbody:\n'+body);
console.log('JSON.stringify(err):\n'+JSON.stringify(err,null,2));
});
});
/* OUTPUT:
err:
Error: Unspecified error
body:
undefined
JSON.stringify(err):
{
"name": "Error",
"scope": "couch",
"status_code": 500,
"status-code": 500,
"request": {
"method": "POST",
"headers": {
"content-type": "application/json",
"accept": "application/json"
},
"uri": "http://localhost:5984/underscore",
"body": "{\"foo\":\"bar\",\"_ISNEW\":true}",
"jar": false
},
"headers": {
"date": "Mon, 04 Jun 2012 16:55:56 GMT",
"content-type": "application/json",
"cache-control": "must-revalidate",
"status-code": 500,
"uri": "http://localhost:5984/underscore"
},
"errid": "non_200",
"error": "doc_validation",
"reason": "Bad special document member: _ISNEW",
"description": "Unspecified error",
"stacktrace": [
"Error: Unspecified error",
" at Request._callback (/home/source/project/nodecuizini/node_modules/nano/nano.js:286:39)",
" at Request.callback (/home/source/project/nodecuizini/node_modules/nano/node_modules/request/main.js:119:22)",
" at Request.<anonymous> (native)",
" at Request.emit (events.js:70:17)",
" at Request.<anonymous> (/home/source/project/nodecuizini/node_modules/nano/node_modules/request/main.js:521:16)",
" at Request.emit (events.js:67:17)",
" at IncomingMessage.<anonymous> (/home/source/project/nodecuizini/node_modules/nano/node_modules/request/main.js:483:14)",
" at IncomingMessage.emit (events.js:88:20)",
" at HTTPParser.onMessageComplete (http.js:137:23)"
]
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment