How to use the couchbase.Connection 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 couchbaselabs / DeveloperDay / Nodejs / 01_connect.js View on Github external
// vim:ts=2 sw=2:

var couchnode = require('couchbase');

console.log("--------------------------------------------------------------------------");
console.log("Couchbase Connections");
console.log("--------------------------------------------------------------------------");


var cb = new couchnode.Connection({
    "password": "",
    "host": "localhost",
    "bucket": "default"
  }, 
  function(err) {
    if (err) {
      throw (err)
    }
    console.log( "Information about Couchase Object" );
    console.log( cb );
    console.log("\n\n--------------------------------------------------------------------------");
    process.exit(0); 
  }
);
github couchbaselabs / expiry-notifier / routes / rest.js View on Github external
exports.setup = function (req, res) {
	db = new couchbase.Connection({
		host: req.params.host + ":" + req.params.port,
		bucket: req.params.bucket,
		connectionTimeout: '500'
	}, function (err) {
		if (err) {
			console.log('=>DB CONNECTION ERR:', err);
		} else {
			console.log('=>DB CONNECTED');
		}});
  
	// Create index
	var iterator_list = {
			map: ['function(doc, meta) {emit(meta.id,meta.expiration);}'].join('\n ')
		}
    
	// Create Design Document
github couchbaselabs / DeveloperDay / Nodejs / 02_storage.js View on Github external
// vim: ts=2 sw=2:
var Connection = require('couchbase').Connection;

console.log("--------------------------------------------------------------------------");
console.log("Couchbase Storage Operations");
console.log("--------------------------------------------------------------------------");

var cb = new Connection({
  "password": "",
  "host": "localhost",
  "bucket": "default"
  }, function(err) {
  if (err) {
    throw (err)
  }
  console.log("Set a Key-Value and Get the Key-Value");
  cb.set("mytest", "my value", function(err, result) {
    // in the call back
    cb.get("mytest", function(err, result) {
      console.log("cb.get(\"mytest\") : " + result.value);

      console.log("\nTry to Add the same key, raises exception");
      cb.add("mytest", "my value", function(err, result) {
        if (err) {
github couchbaselabs / DeveloperDay / Nodejs / 04_retrieve.js View on Github external
name : "John Smith",
  email : "jsmith@email.com",
  password : "p4ssw0rd",
  logins : 0
}

var userData2 = {
  doctype : "learn",
  username : "xsmith",
  name : "Xavier Smith",
  email : "xsmith@email.com",
  password : "p4ssw0rd",
  logins : 0
}

var cb = new Connection({
	"password": "",
	"host": "localhost",
	"bucket": "default"
}, function(err) {
	if (err) {
		throw (err)
	}



	cb.set( userData1.email , userData1, function(err, result) {
		var resultUser1 = result;
		cb.set( userData2.email , userData2, function(err, result) {
			console.log( "User 1 and User2 saved" );
			var resultUser2 = result;
github couchbaselabs / DeveloperDay / Nodejs / 03_storage_json.js View on Github external
var Connection = require('couchbase').Connection;

console.log("--------------------------------------------------------------------------");
console.log("Couchbase JSON Doc Storage");
console.log("--------------------------------------------------------------------------");

var cb = new Connection({
	"password": "",
    "host": "localhost",
	"bucket": "default"
}, function(err) {
	if (err) {
		throw (err)
	}


	var myDoc = {
		doctype : "test",
	   	name : "John Smith"
	};
	
	console.log("Set Document");
	cb.set("mydoc", myDoc, function(err, result) {