How to use the couchbase.connect function in couchbase

To help you get started, we’ve selected a few couchbase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tgrall / couchbase-node-ideas / app.js View on Github external
var express = require('express'),
	driver = require('couchbase'),
	routes = require('./routes')
	;

dbConfiguration = {
	"hosts": ["localhost:8091"],
	"bucket": "ideas"
};


driver.connect(dbConfiguration, function(err, cb) {
	if (err) {
		throw (err)
	}


	var app = module.exports = express();
	// Configuration
	app.configure(function() {
		app.set('views', __dirname + '/views');
		app.engine('.html', require('ejs').renderFile);
		app.set('view engine', 'html');
		app.set('view options', {
			layout: false
		});
		app.use(express.bodyParser());
		app.use(express.methodOverride());
github mozilla / picl-server / lib / kvstore / couchbase.js View on Github external
function cas(key, value, casid, cb) {
      couchbase.connect(options, function(err, bucket) {
        if (err) return cb(err);
        // Couchbase has different methods for "set if not exists" and
        // "set if not modified".  This function is the common callback
        // logic to be aplied after either.
        function handler(err) {
          if (err && err.code === couchbase.errors.keyAlreadyExists) {
            return cb(kvstore.ERROR_CAS_MISMATCH);
          }
          cb(err);
        }
        if (casid === null) {
          bucket.add(key, value, handler);
        } else {
          bucket.set(key, value, {cas: casid}, handler);
        }
      });
github mozilla / picl-server / lib / kvstore / couchbase.js View on Github external
function set(key, value, cb) {
      couchbase.connect(options, function(err, bucket) {
        if (err) return cb(err);
        bucket.set(key, value, function(err) {
          cb(err);
        });
      });
    }