Couchbase Node.js Client Library (Official)

Overview

Couchbase Node.js Client

The Node.js SDK library allows you to connect to a Couchbase cluster from Node.js. It is a native Node.js module and uses the very fast libcouchbase library to handle communicating to the cluster over the Couchbase binary protocol.

Useful Links

Source - https://github.com/couchbase/couchnode

Bug Tracker - https://www.couchbase.com/issues/browse/JSCBC

Couchbase Developer Portal - https://docs.couchbase.com/

Release Notes - https://docs.couchbase.com/nodejs-sdk/3.0/project-docs/sdk-release-notes.html

Installing

To install the lastest release using npm, run:

npm install couchbase

To install the development version directly from github, run:

npm install "git+https://github.com/couchbase/couchnode.git#master"

Introduction

Connecting to a Couchbase bucket is as simple as creating a new Cluster instance to represent the Cluster you are using, and then using the bucket and collection commands against this to open a connection to open your specific bucket and collection. You are able to execute most operations immediately, and they will be queued until the connection is successfully established.

Here is a simple example of instantiating a connection, adding a new document into the bucket and then retrieving its contents:

var couchbase = require('couchbase');
var cluster = new couchbase.Cluster('couchbase://127.0.0.1', {
  username: 'username',
  password: 'password',
});
var bucket = cluster.bucket('default');
var coll = bucket.defaultCollection();

coll.upsert('testdoc', { name: 'Frank' }, (err, res) => {
  if (err) throw err;

  coll.get('testdoc', (err, res) => {
    if (err) throw err;

    console.log(res.value);
    // {name: Frank}
  });
});

Documentation

An extensive documentation is available on the Couchbase website - https://docs.couchbase.com/nodejs-sdk/3.0/hello-world/start-using-sdk.html - including numerous examples and code samples.

Visit our Couchbase Node.js SDK forum for help. Or get involved in the Couchbase Community on the Couchbase website.

Source Control

The source code is available at https://github.com/couchbase/couchnode. Once you have cloned the repository, you may contribute changes through our gerrit server. For more details see CONTRIBUTING.md.

To execute our test suite, run make test from the root directory.

To execute our code coverage, run make cover from the root directory.

In addition to the full test suite and full code coverage, you may additionally execute a subset of the tests which excludes slow-running tests for quick verifications. These can be run through make fasttest and make fastcover respectively.

Finally, to build the API reference for the project, run make docs from the root directory, and a docs folder will be created with the api reference.

License

Copyright 2013 Couchbase Inc.

Licensed under the Apache License, Version 2.0.

See LICENSE for further details.

Comments
  • Do not JSON.parse id_range in MockBucket._execView

    Do not JSON.parse id_range in MockBucket._execView

    startkey_docid and endkey_docid are either undefined, or strings containing a doc id. As such, they shouldn't be parsed. This is already the behavior of the real implementation. The mock implementation is failing my tests, although it works with the real one.

    The change for group_level is only a simplification in JS.

    opened by KoltesDigital 16
  • FIX sort order of view entries with compound keys in mock mode

    FIX sort order of view entries with compound keys in mock mode

    The way keys are compared in the Bucket Mock results in a wrong sort order for compound keys with integers.

    In Mock mode I get view results like that:

    [1,1]
    [1,10]
    [1,100]
    [1,2]
    [1,3]
    
    opened by snrbrnjna 15
  • added flags back to store and get functions

    added flags back to store and get functions

    Currently the only way to operate on document flags is to implement the bucket-wide transcoder functions. However when the application itself already handles encoding/decoding (in our case for compatibility between many data stores), the transcoder functions become more of a nuisance than a feature. i.e. we already have serialised UTF-8 or Binary data and know what the data type should be, e.g. JSON, in this case we would like to set the flags directly as was available in couchnode v1.x.

    This pull request re-implements this feature by allowing you to pass in the flags options arguments for all store operations and returns it as the last argument of get operation callbacks.

    I tried to make the implementation as minimal and backwards compatible as possible.

    opened by AlmirKadric 14
  • Bump Nan to 1.5.1, adds io.js 1.0.1 support

    Bump Nan to 1.5.1, adds io.js 1.0.1 support

    Yo,

    this adds io.js 1.0.X support and bumps to Nan 1.5.1 (adds 0.11.XX support in terms of node-legacy).

    _RFC._

    jfyi: The "Orphan:" prefix indicates that there is neither a ticket for this change nor do I want to create an Issue addressing this change.

    opened by 19h 13
  • Fixed Geospatial Queries

    Fixed Geospatial Queries

    According to https://docs.couchbase.com/server/6.0/fts/fts-geospatial-queries.html#specifying-distances Radius-Based is like following

    {
      "from": 0,
      "size": 10,
      "query": {
        "location": {
          "lon": -2.235143,
          "lat": 53.482358
         },
          "distance": "100mi",
          "field": "geo"
        },
      "sort": [
        {
          "by": "geo_distance",
          "field": "geo",
          "unit": "mi",
          "location": {
          "lon": -2.235143,
          "lat": 53.482358
          }
        }
      ]
    }
    
    opened by sm2017 12
  • Switch from JSHint to ESlint

    Switch from JSHint to ESlint

    ESlint is a newer pluggable linter that does both the job of JSHint and JSCS (the JSCS team has actually joined the ESLint team)

    This PR is both a translation of the existing JSHint rules and a set of fixes based on issues found. It is structured so that if there is a rule you want changed it should be easy for me to rollback the commit and update the .eslintrc

    Let me know if you have any questions or want any rule changes

    opened by corbinu 9
  • Update nan to 1.8.4

    Update nan to 1.8.4

    This enables iojs 2.x.x it is just a very small change to remove a warning and a nan bump. Honestly would probably be easier to just just redo yourself but needed it for my work so figured I would submit

    opened by corbinu 8
  • Bucket multi helpers

    Bucket multi helpers

    As explained in this issue every multi method has been removed from couchnode (only getMulti still exists). This commit is a proposal to reintroduce them — but only as helpers, this implementation only wraps existing code and do not use libcouchbase directly.

    Once in a while, using an upsertMulti can be useful, so instead of letting everyone re-implement it all over again, it seems appropriate to offer it with couchnode.

    This implementation relies heavily on the previous getMulti implementation. A _multi method gather every bit of code while each operation (upsert, insert, touch) only calls it with the proper arguments. This _multi method handles validation, options (single's options override multi options) and produces a standard output.

    The code tries to stick as much as possible to the existing coding standards and a test + a documentation is written for every bit of it.

    As an example:

    bucket.getAndLockMulti([key1, key2, key3], function(err, v) {
      assert(err === 1);
      assert(v[key1].cas);
      assert(v[key1].value);
      assert(!v[key1].cas);
      assert(v[key1].error);
    })
    
    var kv = {};
    kv[key1] = {value: 'foo'};
    kv[key2] = {value: 'bar', expiry: 5};
    bucket.upsertMulti(kv, {expiry: 10}, function(err, v) {
      assert(err === 2);
    })
    

    ps. was not able to submit this via review.couchbase.com, has sign the Contributor Agreement, but got no mail

    opened by yamsellem 8
  • Switch from JSHint to ESlint 2

    Switch from JSHint to ESlint 2

    ESlint is a newer pluggable linter that does both the job of JSHint and JSCS (the JSCS team has actually joined the ESLint team)

    This PR is both a translation of the existing JSHint rules and a set of fixes based on issues found. It is structured so that if there is a rule you want changed it should be easy for me to rollback the commit and update the .eslintrc

    Let me know if you have any questions or want any rule changes

    opened by corbinu 7
  • Updated to libcouchbase 2.5.8 - Fixes

    Updated to libcouchbase 2.5.8 - Fixes "Got memcached EINVAL!".

    Hi,

    My couchbase-backed hapi server kept crashing with "Got memcached EINVAL!" as described on the couchbase forums.

    According to a link in the forum thread above the issue was coming from libcouchbase and has been fixed in version 2.5.8.

    So I've updated the dependency in couchnode to libcouchbase 2.5.8, and it solved my issue.

    To be honest, I don't perfectly understand what I did, being quite unfamiliar with node-gyp :)

    That being said, I've been able to run the test suite successfully both before and after the update of the dependency (using the real bucket, too), so I guess this contribution is at least a good base for discussion.

    Let me know what you think!

    opened by djfm 6
  • Don't throw errors in node.js

    Don't throw errors in node.js

    You shouldn't throw errors inside functions that use callbacks. This pull request isn't extensively tested, but the existing tests pass and it's certainly a step in the right direction.

    opened by BryanDonovan 6
  • Bump json5 from 2.1.3 to 2.2.3

    Bump json5 from 2.1.3 to 2.2.3

    Bumps json5 from 2.1.3 to 2.2.3.

    Release notes

    Sourced from json5's releases.

    v2.2.3

    v2.2.2

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).

    v2.2.1

    • Fix: Removed dependence on minimist to patch CVE-2021-44906. (#266)

    v2.2.0

    • New: Accurate and documented TypeScript declarations are now included. There is no need to install @types/json5. (#236, #244)
    Changelog

    Sourced from json5's changelog.

    v2.2.3 [code, diff]

    v2.2.2 [code, diff]

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).

    v2.2.1 [code, diff]

    • Fix: Removed dependence on minimist to patch CVE-2021-44906. (#266)

    v2.2.0 [code, diff]

    • New: Accurate and documented TypeScript declarations are now included. There is no need to install @types/json5. (#236, #244)
    Commits
    • c3a7524 2.2.3
    • 94fd06d docs: update CHANGELOG for v2.2.3
    • 3b8cebf docs(security): use GitHub security advisories
    • f0fd9e1 docs: publish a security policy
    • 6a91a05 docs(template): bug -> bug report
    • 14f8cb1 2.2.2
    • 10cc7ca docs: update CHANGELOG for v2.2.2
    • 7774c10 fix: add proto to objects and arrays
    • edde30a Readme: slight tweak to intro
    • 97286f8 Improve example in readme
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
Releases(v3.2.6)
The Official MongoDB Node.js Driver

MongoDB NodeJS Driver The official MongoDB driver for Node.js. NOTE: v3.x released with breaking API changes. You can find a list of changes here. Ver

mongodb 9.6k Dec 28, 2022
Official turtleDB project

Overview • Getting Started • Features • Contributors • License • Overview turtleDB is a JavaScript framework and in-browser database for developers to

turtleDB 436 Dec 24, 2022
Run official FLAC tools `flac` and `metaflac` as WebAssembly, on browsers or Deno.

flac.wasm Run official FLAC tools flac and metaflac as WebAssembly, on browsers or Deno. Currently we have no plans on supporting Node.js. Try it onli

Pig Fang 15 Aug 21, 2022
PostgreSQL client for node.js.

node-postgres Non-blocking PostgreSQL client for Node.js. Pure JavaScript and optional native libpq bindings. Monorepo This repo is a monorepo which c

Brian C 10.9k Jan 9, 2023
A pure node.js JavaScript Client implementing the MySQL protocol.

mysql Table of Contents Install Introduction Contributors Sponsors Community Establishing connections Connection options SSL options Connection flags

null 17.6k Jan 1, 2023
🚀 A robust, performance-focused and full-featured Redis client for Node.js.

A robust, performance-focused and full-featured Redis client for Node.js. Supports Redis >= 2.6.12 and (Node.js >= 6). Completely compatible with Redi

Zihua Li 11.6k Jan 8, 2023
Microsoft SQL Server client for Node.js

node-mssql Microsoft SQL Server client for Node.js Supported TDS drivers: Tedious (pure JavaScript - Windows/macOS/Linux, default) Microsoft / Contrib

null 2.1k Jan 4, 2023
Node.js client for the Aerospike database

Aerospike Node.js Client An Aerospike add-on module for Node.js. The client is compatible with Node.js v8.x, v10.x (LTS), v12.x (LTS), and v14.x (LTS)

Aerospike 198 Dec 30, 2022
Pulsar Flex is a modern Apache Pulsar client for Node.js, developed to be independent of C++.

PulsarFlex Apache Pulsar® client for Node.js Report Bug · Request Feature About the project Features Usage Contributing About PulsarFlex is a modern A

null 43 Aug 19, 2022
A PostgreSQL client with strict types, detailed logging and assertions.

Slonik A battle-tested PostgreSQL client with strict types, detailed logging and assertions. (The above GIF shows Slonik producing query logs. Slonik

Gajus Kuizinas 3.6k Jan 3, 2023
A web client port-scanner written in GO, that supports the WASM/WASI interface for Browser WebAssembly runtime execution.

WebAssembly Port Scanner Written in Go with target WASM/WASI. The WASM main function scans all the open ports in the specified range (see main.go), vi

Avi Lumelsky 74 Dec 27, 2022
An open letter against Apple's new privacy-invasive client-side content scanning.

Apple Privacy Letter An open letter against Apple's new privacy-invasive client-side content scanning technology. View the letter Sign the letter This

Nadim Kobeissi 655 Dec 19, 2022
Reseda - reseda-client for the reseda-vpn network

Usage Create an App # with npx $ npx create-nextron-app my-app --example with-typescript # with yarn $ yarn create nextron-app my-app --example with-

Ben White 3 Dec 28, 2022
curl for GraphQL with autocomplete, subscriptions and GraphiQL. Also a dead-simple universal javascript GraphQL client.

graphqurl graphqurl is a curl like CLI for GraphQL. It's features include: CLI for making GraphQL queries. It also provisions queries with autocomplet

Hasura 3.2k Jan 3, 2023
Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker

Instructions Starter template for ?? NestJS and Prisma. Checkout NestJS Prisma Schematics to automatically add Prisma support to your Nest application

notiz.dev 1.6k Jan 4, 2023
A tool to inject javascript into the Steam Deck client.

Steam Deck UI Inject A tool to inject javascript into the Steam Deck client. How it works This tool works by taking advantage of the remote debugging

marios 30 Dec 5, 2022
TypeScript client for Tile38 geo-database

Tile38-ts tier.engineering · Report Bug · Request Feature Table of Contents About The Project Built With Getting Started Requirements Installation Com

Tier Mobility SE 22 Dec 29, 2022
🌐 API and CLIENT API for FiveM to externalize database responsibilities.

?? Query API API and CLIENT API for FiveM to externalize database responsibilities. FAQ Is the project finished? Definitely NOT, this is a first versi

Thiago Neubern 2 Jul 5, 2022