How to use the couchbase.Error 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 dsfields / couchbase-promises / lib / mock-cluster.js View on Github external
this.get(key, (err, res) => {
    if (isFailure(err)) return cb(err);

    const val = res.value;

    if (!Array.isArray(val))
      return cb(new couchbase.Error('Not a set'));

    cb(undefined, { cas: res.cas, value: val.indexOf(value) !== -1 });
  });
};
github dsfields / couchbase-promises / lib / mock-cluster.js View on Github external
this.get(key, (err, res) => {
    if (isFailure(err)) return cb(err);

    const val = res.value;

    if (!val.isMap)
      return cb(new couchbase.Error('Not a map'));

    if (!val.hasOwnProperty(path))
      return cb(new couchbaseError('Path invalid'));

    cb(undefined, { cas: res.cas, value: val[path] });
  });
};
github dsfields / couchbase-promises / lib / mock-cluster.js View on Github external
this.get(key, (err, res) => {
    if (isFailure(err)) return cb(err);

    if (!Array.isArray(res.value))
      return cb(new couchbase.Error('Not a list'));

    if (index >= res.value.length)
      return cb(new couchbaseError('Index out of range'));

    cb(undefined, { cas: res.cas, value: res.value[index] });
  });
};
github dsfields / couchbase-promises / lib / mock-cluster.js View on Github external
this.get(key, (err, res) => {
    if (isFailure(err)) {
      if (elv(options) && options.createQueue) {
        const newQueue = [ value ];
        return self.insert(key, newQueue, (e, r) => {
          if (isFailure(e)) return cb(e);
          cb(undefined, { cas: r.cas, value: newQueue });
        });
      } else {
        return cb(err);
      }
    }

    if (!Array.isArray(res.value))
      return cb(new couchbase.Error('Not a queue'));

    const val = res.value;
    val.push(value);

    self.replace(key, val, (e, r) => {
      if (elv(e)) return cb(e);
      cb(undefined, { cas: r.cas, value: val });
    });
  });
};