![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
couchbase-promises
Advanced tools
Just like the Couchbase Node.js SDK, but with the addition of *Async()
methods that return A+ Promises for all methods that contain a Node.js callback parameter. This module functions as a drop-in replacement for the couchbase module.
The current version supports Couchbase Node.js SDK version 2.2.1.
Promises are created using the Bluebird Promises library. If you absolutely must use native ECMAScript Promises, then have a look at couchbase-es-promises. I highly recommend avoiding couchbase-es-promises, as Bluebird is compatible with native promises, and offers an order of magnitude more performance.
Usage is almost exactly the same as the native SDK, but with the added ability to use Promises instead of callbacks.
A user repository module with a simple lookup...
const couchbase = require('couchbase-promises');
const cluster = new couchbase.Cluster('couchbase://127.0.0.1');
const bucket = cluster.openBucket();
const UserNotFoundError = () => {
Error.call(this);
Error.captureStackTrace(this, UserNotFoundError);
this.message = "User not found.";
}
module.exports = {
UserNotFoundError: UserNotFoundError,
getUserAsync: function(userId) {
return bucket.getAsync(userId)
.then(function(result) {
return {
user: result.value,
meta: {
etag: result.cas
}
};
}).catch(couchbase.Error, function(e) {
if (e.code === couchbase.errors.keyNotFound)
throw new UserNotFoundError();
throw e;
});
}
};
The the couchbase
module only provides batch operation support for key lookups (via Bucket.prototype.getMulti()
). The couchbase-promises
module provides a few extra methods on the Bucket
class for performing batch operations.
Bucket.prototype.insertMultiAsync(docs, options)
Inserts multiple documents into the bucket. This method will create individual insert operations for each document using Promise.all()
.
Returns: a Promise
that resolves with a Summary
object. This Promise
will always be fulfilled. Any errors that occur will be specified in the resolved Summary
.
Parameters
docs
: a Map
or an object where each property name is the key of the document to insert.options
: an optional object to pass to the native insert()
method.Bucket.prototype.removeMultiAsyc(keys, options)
Removes multiple documents in the bucket. This method will create individual remove operations for each key using with Promisea.all()
.
Returns: a Promise
that resolves with a Summary
object. This Promise
will always be fulfilled. Any errors that occur will be specified in the resolved Summary
.
Parameters
keys
: a Set
or an Array
of keys to remove.options
: an optional object to pass to the native remove()
method.Summary
ClassContains a summary of a bulk operation. Keys include:
hasErrors
: a Boolean value indicating whether or not any items failed in the bulk operation.keys
: an array of keys that were used in the bulk operations.results
: an object with properties for key used in the bulk operation.
success
: a Boolean value indicating whether or not the the individual operation succeeded.err
: the error returned from Couchbase if the operation was not successful.result
: the result object returned from Couchbase.2.1.1
couchbase
to the latest version (2.2.2).FAQs
An A+ Promises wrapper for the Couchbase SDK with added support for batch mutation operations.
The npm package couchbase-promises receives a total of 4 weekly downloads. As such, couchbase-promises popularity was classified as not popular.
We found that couchbase-promises demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.