Skip to content

Instantly share code, notes, and snippets.

@peytonmcnully
Created January 18, 2020 02:39
Show Gist options
  • Save peytonmcnully/1474e45223c2067bc6d3c9968ac0ebfe to your computer and use it in GitHub Desktop.
Save peytonmcnully/1474e45223c2067bc6d3c9968ac0ebfe to your computer and use it in GitHub Desktop.
download both files
var couchbase = require('couchbase')
var cluster = new couchbase.Cluster('couchbase://167.172.139.14/');
cluster.authenticate('Administrator', 'andystrator');
var bucket = cluster.openBucket('bucketohshiii');
var N1qlQuery = couchbase.N1qlQuery;
bucket.manager().createPrimaryIndex(function() {
bucket.upsert('user:king_arthur', {
'email': '[email protected]', 'interests': ['Holy Grail', 'African Swallows']
},
function (err, result) {
bucket.get('user:king_arthur', function (err, result) {
console.log('Got result: %j', result.value);
bucket.query(
N1qlQuery.fromString('SELECT * FROM bucketname WHERE $1 in interests LIMIT 1'),
['African Swallows'],
function (err, rows) {
console.log("Got rows: %j", rows);
});
});
});
});
{
"name": "gator",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"couchbase": "^2.6.10"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment