Skip to content

Commit

Permalink
Replace mentions of 'meta'
Browse files Browse the repository at this point in the history
This nomenclature was sadly passed on from the previous versions of the
client. In the new API there is no "meta", but only a single result
object which contains both the value and any associated metadata.

Mentions of meta have been replaced with 'options' or 'result' where
applicable. Mentions of 'meta' are still within the views tests where
this 'meta' refers to an argument passed to the server-side view
function and is not related to the SDK terminology.

Change-Id: I7acc028d694ed4894a22235d9213742e995817dc
Reviewed-on: http://review.couchbase.org/29417
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Brett Lawson <brett19@gmail.com>
  • Loading branch information
mnunberg authored and brett19 committed Oct 9, 2013
1 parent 0baba15 commit ece5200
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 101 deletions.
10 changes: 5 additions & 5 deletions benchmarks/memdbench.js
Expand Up @@ -129,7 +129,7 @@ function scheduleMemcached(cb) {
cb.set(curKey, value, 0, function(err) { cb.set(curKey, value, 0, function(err) {
markOperation(err); markOperation(err);


cb.get(curKey, function(err, meta) { cb.get(curKey, function(err, result) {
markOperation(err); markOperation(err);
scheduleMemcached(cb); scheduleMemcached(cb);
}); });
Expand All @@ -138,9 +138,9 @@ function scheduleMemcached(cb) {


function scheduleCouchbase(cb) { function scheduleCouchbase(cb) {
var curKey = getKey(); var curKey = getKey();
cb.set(curKey, value, {}, function(err, meta) { cb.set(curKey, value, {}, function(err, result) {
markOperation(err); markOperation(err);
cb.get(curKey, function(err, meta) { cb.get(curKey, function(err, result) {
markOperation(err); markOperation(err);
scheduleCouchbase(cb); scheduleCouchbase(cb);
}) })
Expand All @@ -149,9 +149,9 @@ function scheduleCouchbase(cb) {


function scheduleNode(cb) { function scheduleNode(cb) {
var curKey = getKey(); var curKey = getKey();
cb.Set(curKey, value, function(err, meta) { cb.Set(curKey, value, function(err, result) {
markOperation(err); markOperation(err);
cb.Get(curKey, function(err, meta) { cb.Get(curKey, function(err, result) {
markOperation(err); markOperation(err);
scheduleNode(cb); scheduleNode(cb);
}); });
Expand Down
34 changes: 17 additions & 17 deletions lib/couchbase.js
Expand Up @@ -263,17 +263,17 @@ Connection.prototype._interceptEndure = function(key, options, globalOptions, is
* @ignore * @ignore
*/ */
Connection.prototype._invokeStorage = function(tgt, argList) { Connection.prototype._invokeStorage = function(tgt, argList) {
var meta, callback; var options, callback;
if (argList.length === 3) { if (argList.length === 3) {
meta = {}; options = {};
meta[argList[0]] = { value: argList[1] }; options[argList[0]] = { value: argList[1] };
callback = argList[2]; callback = argList[2];
} else { } else {
meta = _mergeParams(argList[0], { value: argList[1] }, argList[2] ); options = _mergeParams(argList[0], { value: argList[1] }, argList[2] );
callback = argList[3]; callback = argList[3];
} }
tgt.call(this._cb, meta, null, tgt.call(this._cb, options, null,
this._interceptEndure(argList[0], meta, {}, false, callback)); this._interceptEndure(argList[0], options, {}, false, callback));
}; };


/** /**
Expand Down Expand Up @@ -775,7 +775,7 @@ Connection.prototype.setMulti = function(kv, options, callback) {
* @see Connection#add * @see Connection#add
* @see Connection#setMulti * @see Connection#setMulti
*/ */
Connection.prototype.addMulti = function(kv, meta, callback) { Connection.prototype.addMulti = function(kv, options, callback) {
this._multiHelper(this._cb.addMulti, arguments); this._multiHelper(this._cb.addMulti, arguments);
}; };


Expand All @@ -789,7 +789,7 @@ Connection.prototype.addMulti = function(kv, meta, callback) {
* @see Connection#replace * @see Connection#replace
* @see Connection#setMulti * @see Connection#setMulti
*/ */
Connection.prototype.replaceMulti = function(kv, meta, callback) { Connection.prototype.replaceMulti = function(kv, options, callback) {
this._multiHelper(this._cb.replaceMulti, arguments); this._multiHelper(this._cb.replaceMulti, arguments);
}; };


Expand All @@ -803,7 +803,7 @@ Connection.prototype.replaceMulti = function(kv, meta, callback) {
* @see Connection#append * @see Connection#append
* @see Connection#setMulti * @see Connection#setMulti
*/ */
Connection.prototype.appendMulti = function(kv, meta, callback) { Connection.prototype.appendMulti = function(kv, options, callback) {
this._multiHelper(this._cb.appendMulti, arguments); this._multiHelper(this._cb.appendMulti, arguments);
}; };


Expand All @@ -817,7 +817,7 @@ Connection.prototype.appendMulti = function(kv, meta, callback) {
* @see Connection#prepend * @see Connection#prepend
* @see Connection#setMulti * @see Connection#setMulti
*/ */
Connection.prototype.prependMulti = function(kv, meta, callback) { Connection.prototype.prependMulti = function(kv, options, callback) {
this._multiHelper(this._cb.prependMulti, arguments); this._multiHelper(this._cb.prependMulti, arguments);
}; };


Expand All @@ -831,7 +831,7 @@ Connection.prototype.prependMulti = function(kv, meta, callback) {
* @see Connection#get * @see Connection#get
* @see Connection#setMulti * @see Connection#setMulti
*/ */
Connection.prototype.getMulti = function(kv, meta, callback) { Connection.prototype.getMulti = function(kv, options, callback) {
this._multiHelper(this._cb.getMulti, arguments); this._multiHelper(this._cb.getMulti, arguments);
}; };


Expand All @@ -845,7 +845,7 @@ Connection.prototype.getMulti = function(kv, meta, callback) {
* @see Connection#lock * @see Connection#lock
* @see Connection#unlockMulti * @see Connection#unlockMulti
*/ */
Connection.prototype.lockMulti = function(kv, meta, callback) { Connection.prototype.lockMulti = function(kv, options, callback) {
this._multiHelper(this._cb.lockMulti, arguments); this._multiHelper(this._cb.lockMulti, arguments);
}; };


Expand All @@ -862,7 +862,7 @@ Connection.prototype.lockMulti = function(kv, meta, callback) {
* @see Connection#unlock * @see Connection#unlock
* @see Connection#setMulti * @see Connection#setMulti
*/ */
Connection.prototype.unlockMulti = function(kv, meta, callback) { Connection.prototype.unlockMulti = function(kv, options, callback) {
this._multiHelper(this._cb.unlockMulti, arguments); this._multiHelper(this._cb.unlockMulti, arguments);
}; };


Expand All @@ -873,7 +873,7 @@ Connection.prototype.unlockMulti = function(kv, meta, callback) {
* @param {object=} options * @param {object=} options
* @param {MultiCallback|KeyCallback} callback * @param {MultiCallback|KeyCallback} callback
*/ */
Connection.prototype.removeMulti = function(kv, meta, callback) { Connection.prototype.removeMulti = function(kv, options, callback) {
this._multiHelper(this._cb.deleteMulti, arguments); this._multiHelper(this._cb.deleteMulti, arguments);
}; };


Expand All @@ -887,7 +887,7 @@ Connection.prototype.removeMulti = function(kv, meta, callback) {
* *
* @see Connection#setMulti * @see Connection#setMulti
*/ */
Connection.prototype.incrMulti = function(kv, meta, callback) { Connection.prototype.incrMulti = function(kv, options, callback) {
this._multiHelper(this._cb.incrMulti, arguments); this._multiHelper(this._cb.incrMulti, arguments);
}; };


Expand All @@ -902,7 +902,7 @@ Connection.prototype.incrMulti = function(kv, meta, callback) {
* @see Connection#decr * @see Connection#decr
* @see Connection#set * @see Connection#set
*/ */
Connection.prototype.decrMulti = function(kv, meta, callback) { Connection.prototype.decrMulti = function(kv, options, callback) {
this._multiHelper(this._cb.decrMulti, arguments); this._multiHelper(this._cb.decrMulti, arguments);
}; };


Expand All @@ -913,7 +913,7 @@ Connection.prototype.decrMulti = function(kv, meta, callback) {
* @param {object} kv * @param {object} kv
* @param {MultiCallback|KeyCallback} callback * @param {MultiCallback|KeyCallback} callback
*/ */
Connection.prototype.observeMulti = function(kv, meta, callback) { Connection.prototype.observeMulti = function(kv, options, callback) {
this._multiHelper(this._cb.observeMulti, arguments); this._multiHelper(this._cb.observeMulti, arguments);
}; };


Expand Down
4 changes: 2 additions & 2 deletions test/add.js
Expand Up @@ -12,12 +12,12 @@ describe('#add', function() {
cb.remove(testkey, function(){ cb.remove(testkey, function(){
cb.add(testkey, "bar", H.okCallback(function() { cb.add(testkey, "bar", H.okCallback(function() {
// try to add existing key, should fail // try to add existing key, should fail
cb.add(testkey, "baz", function (err, meta) { cb.add(testkey, "baz", function (err, result) {
assert(err, "Can't add object at empty key"); assert(err, "Can't add object at empty key");
done(); done();
}); });
})); }));
}); });
}); });


}); });
18 changes: 9 additions & 9 deletions test/durability.js
Expand Up @@ -9,12 +9,12 @@ describe('#durability', function() {
it('should successfully observe', function(done) { it('should successfully observe', function(done) {
var key = H.genKey("observe"); var key = H.genKey("observe");


cb.set(key, "value", H.okCallback(function(meta){ cb.set(key, "value", H.okCallback(function(result){
cb.observeMulti([key], {}, H.okCallback(function(meta){ cb.observeMulti([key], {}, H.okCallback(function(result){
assert(typeof meta == "object"); assert(typeof result == "object");
assert(key in meta); assert(key in result);
assert(typeof meta[key] == 'object'); assert(typeof result[key] == 'object');
assert('cas' in meta[key][0]); assert('cas' in result[key][0]);
done(); done();
})); }));
})); }));
Expand All @@ -26,11 +26,11 @@ describe('#durability', function() {
var key = H.genKey("endure"); var key = H.genKey("endure");


cb.set(key, "value", {persist_to:1, replicate_to:0}, cb.set(key, "value", {persist_to:1, replicate_to:0},
H.okCallback(function(meta){ H.okCallback(function(result){
cb.remove(key, {persist_to:1, replicate_to:0}, cb.remove(key, {persist_to:1, replicate_to:0},
H.okCallback(function(mera) { H.okCallback(function(result) {
cb.add(key, "value", {persist_to:1, replicate_to:0}, cb.add(key, "value", {persist_to:1, replicate_to:0},
H.okCallback(function(meta){ H.okCallback(function(result){
done(); done();
})); }));
})); }));
Expand Down
18 changes: 9 additions & 9 deletions test/get-set.js
Expand Up @@ -8,15 +8,15 @@ describe('#get/set', function() {


it('should work in basic cases', function(done) { it('should work in basic cases', function(done) {
var key = H.genKey("set"); var key = H.genKey("set");
cb.set(key, "bar", H.okCallback(function(firstmeta){ cb.set(key, "bar", H.okCallback(function(firstresult){
// nothing broke // nothing broke
cb.set(key, "baz", H.okCallback(function(secondmeta){ cb.set(key, "baz", H.okCallback(function(secondresult){
assert.notDeepEqual(firstmeta.cas, secondmeta.cas, "CAS should change"); assert.notDeepEqual(firstresult.cas, secondresult.cas, "CAS should change");
cb.set(key, "bam", firstmeta, function(err, meta){ cb.set(key, "bam", firstresult, function(err, result){
assert(err, "Key should fail with stale CAS"); assert(err, "Key should fail with stale CAS");
cb.get(key, H.okCallback(function(result){ cb.get(key, H.okCallback(function(result){
assert.equal(result.value, "baz"); assert.equal(result.value, "baz");
cb.set(key, "grr", secondmeta, H.okCallback(function(meta){ cb.set(key, "grr", secondresult, H.okCallback(function(result){
cb.get(key, H.okCallback(function(result){ cb.get(key, H.okCallback(function(result){
assert.equal("grr", result.value); assert.equal("grr", result.value);
done(); done();
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('#get/set', function() {
var value = [1,2,3,4]; var value = [1,2,3,4];
var key = H.genKey("set-utf8-unconvertible"); var key = H.genKey("set-utf8-unconvertible");


cb.set(key, value, { format: 'raw' }, function(err, meta){ cb.set(key, value, { format: 'raw' }, function(err, result){
assert(err); assert(err);
done(); done();
}); });
Expand All @@ -118,11 +118,11 @@ describe('#get/set', function() {
var key = H.genKey("set-raw-format"); var key = H.genKey("set-raw-format");


cb.set(key, buf, H.okCallback(function(){ cb.set(key, buf, H.okCallback(function(){
cb.get(key, H.okCallback(function(meta){ cb.get(key, H.okCallback(function(result){
var doc = meta.value; var doc = result.value;
assert(Buffer.isBuffer(doc)); assert(Buffer.isBuffer(doc));
assert.deepEqual(buf, doc); assert.deepEqual(buf, doc);
assert.equal(meta.flags, couchbase.format.raw); assert.equal(result.flags, couchbase.format.raw);
done(); done();
})); }));
})); }));
Expand Down
20 changes: 10 additions & 10 deletions test/getmulti-setmulti.js
Expand Up @@ -23,19 +23,19 @@ describe('#getMulti/setMulti', function() {
assert.equal(doc.value, values[keys[0]].value); assert.equal(doc.value, values[keys[0]].value);
})); }));


cb.getMulti(keys, null, H.okCallback(function(meta){ cb.getMulti(keys, null, H.okCallback(function(results){
assert.equal(keys.length, Object.keys(meta).length); assert.equal(keys.length, Object.keys(results).length);
Object.keys(meta).forEach(function(k){ Object.keys(results).forEach(function(k){
assert(values[k] !== undefined); assert(values[k] !== undefined);
assert(meta[k] !== undefined); assert(results[k] !== undefined);
assert(meta[k].value === values[k].value); assert(results[k].value === values[k].value);
}); });


done(); done();
})); }));
} }


var setHandler = H.okCallback(function(meta) { var setHandler = H.okCallback(function(results) {
calledTimes++; calledTimes++;
if (calledTimes > 9) { if (calledTimes > 9) {
calledTimes = 0; calledTimes = 0;
Expand All @@ -52,16 +52,16 @@ describe('#getMulti/setMulti', function() {
var goodKey = H.genKey("test-multiget-spooled"); var goodKey = H.genKey("test-multiget-spooled");
var goodValue = 'foo'; var goodValue = 'foo';


cb.set(goodKey, goodValue, function(err, meta) { cb.set(goodKey, goodValue, function(err, result) {
assert.ifError(err); assert.ifError(err);
var keys = [badKey, goodKey]; var keys = [badKey, goodKey];


cb.getMulti(keys, null, function(err, meta) { cb.getMulti(keys, null, function(err, results) {
assert.strictEqual(err.code, couchbase.errors.checkResults); assert.strictEqual(err.code, couchbase.errors.checkResults);
var goodResult = meta[goodKey]; var goodResult = results[goodKey];
assert.equal(goodResult.value, goodValue); assert.equal(goodResult.value, goodValue);


var badResult = meta[badKey]; var badResult = results[badKey];
assert.strictEqual(badResult.error.code, couchbase.errors.keyNotFound); assert.strictEqual(badResult.error.code, couchbase.errors.keyNotFound);


done(); done();
Expand Down
4 changes: 2 additions & 2 deletions test/hashkeys.js
Expand Up @@ -14,7 +14,7 @@ describe('#hashkeys', function() {
cb.set(key, "bar", { hashkey: hashkey }, H.okCallback(function(){ cb.set(key, "bar", { hashkey: hashkey }, H.okCallback(function(){
cb.get(key, { hashkey: hashkey }, H.okCallback(function(result){ cb.get(key, { hashkey: hashkey }, H.okCallback(function(result){
assert.equal(result.value, "bar"); assert.equal(result.value, "bar");
cb.get(key, function(err, meta){ cb.get(key, function(err, result){
assert.ok(err); assert.ok(err);
assert.equal(err.code, couchbase.errors.keyNotFound); assert.equal(err.code, couchbase.errors.keyNotFound);
done(); done();
Expand All @@ -23,4 +23,4 @@ describe('#hashkeys', function() {
})); }));
}); });


}); });
6 changes: 3 additions & 3 deletions test/incr-decr.js
Expand Up @@ -46,7 +46,7 @@ describe('#incr/decr', function() {
var key = H.genKey("incrdecr3"); var key = H.genKey("incrdecr3");


cb.remove(key, function(){ cb.remove(key, function(){
cb.incr(key, function(err, meta){ cb.incr(key, function(err, result){
assert(err, "Error when incrementing key that does not exist"); assert(err, "Error when incrementing key that does not exist");
cb.incr(key, {initial: 500, offset: 20}, H.okCallback(function(result){ cb.incr(key, {initial: 500, offset: 20}, H.okCallback(function(result){
assert.equal(result.value, 500, "Offset is ignored when default is used"); assert.equal(result.value, 500, "Offset is ignored when default is used");
Expand All @@ -69,7 +69,7 @@ describe('#incr/decr', function() {
cb.incr(key, H.okCallback(function(result){ cb.incr(key, H.okCallback(function(result){
assert.equal(result.value, 1); assert.equal(result.value, 1);
setTimeout(function(){ setTimeout(function(){
cb.get(key, function(err, meta){ cb.get(key, function(err, result){
assert(err, "Expiry with arithmetic"); assert(err, "Expiry with arithmetic");
done(); done();
}); });
Expand All @@ -79,4 +79,4 @@ describe('#incr/decr', function() {
}); });
}); });


}); });

0 comments on commit ece5200

Please sign in to comment.