Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Last active August 29, 2015 14:03
Show Gist options
  • Save sideshowcoder/6bd84bf5479112fcb145 to your computer and use it in GitHub Desktop.
Save sideshowcoder/6bd84bf5479112fcb145 to your computer and use it in GitHub Desktop.
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