Create design documents from API
When adding new design documents through the API, the document shows up in the default bucket: "_design/dev_users" but not in the views.
https://gist.github.com/2470976
Any ideas?
Hey Pathe,
What Developer Preview are you using? DP4?
Also, is this the node.js client you're using?
https://github.com/elbart/node-memcache
I'll dig in deeper with that info.
Thanks,
Benjamin
Hi Benjamin,
We're using DP4 with elbart's memcache lib, yes.
Right now, this is not required any more as we moved to a central development database instead of each dev having an instance running.
Anyway, this is the code:
app.get('/dbtest', function(req, res) {
var view = {
"_id": "_design/testdb",
"views": {
"index": {
"map": "function (doc) {\n if(doc.jsonType == \"user\") {\n emit(doc._id, null);\n }\n}"
}
}
};
client.connect();
client.set('_design/testdb', JSON.stringify(view), function(error, result) {
client.close();
console.log(error, result);
});
});The document shows up as a regular document, but not in the views.
Patrick
Design docs must be updated via the REST API using PUT to /default/_design/foobam
If you are hitting the Admin UI port, you may need to prefix the path like this: /couchBase/default/_design/foobam
If written via the get/set API design documents will just be 'normal' data, so it's important to write them via REST to
And, we're planning to add API for managing design documents to all of the official SDKs here shortly.
There's a Java example of how to do this without additional API that should be pretty easy for you to use in whatever language you need. See: http://www.couchbase.com/wiki/display/couchbase/Couchbase+Java+Client+Li...
Mike,
I solved the problems in the node.js library called 'baseview' (https://github.com/PatrickHeneise/baseview). I still have to add the pool-request, but that's coming soon.
Patrick
Anything?