Create a gist now

Instantly share code, notes, and snippets.

Create CouchBase view with node.js
var memcache = require('memcache');
var client = new memcache.Client() = 'localhost'
client.port = 11211;
client.on('error', function(e){
console.log("couchbase error");
var users = {
"_id": "_design/dev_users",
"language": "javascript",
"views": {
"usernames": {
"map": "function (doc) {\n if(doc.jsonType == \"user\") {\n emit(doc.username, doc);\n }\n}"
"emails": {
"map": "function (doc) {\n if(doc.jsonType == \"user\") {\n emit(, doc);\n }\n}"
"spatial": {}
client.set('_design/dev_users', JSON.stringify(users), function(error, result) {
console.log(error, result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment