Last active
August 29, 2015 14:03
-
-
Save sideshowcoder/6bd84bf5479112fcb145 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cb = require("couchbase") | |
var async = require("async") | |
var cluster = new cb.Cluster("couchbase://localhost/") | |
var bucket = cluster.openBucket("default") | |
bucket.queryhosts = ["localhost:8093"] | |
var log = function () { | |
var args = Array.prototype.slice.call(arguments, 0) | |
console.log.apply(null, args.filter(function (e) { return e != null })) | |
} | |
async.series([ | |
function(cb) { | |
bucket.upsert("foo", JSON.stringify({bar: "baz"}), function (err, res) { | |
log(err, res) | |
cb() | |
}) | |
}, | |
function(cb) { | |
bucket.get("foo", function (err, res) { | |
log(err, res) | |
cb() | |
}) | |
}, | |
function(cb) { | |
bucket.query("SELECT * FROM default LIMIT 1", function (err, res) { | |
log(err, res) | |
cb() | |
}) | |
}, | |
function(cb) { | |
bucket.query("SELECT * FROM default WHERE bar = ? LIMIT 1", ['baz'], function (err, res) { | |
log(err, res) | |
cb() | |
}) | |
}, | |
bucket.shutdown.bind(bucket) | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment