npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

feathersjs-couchbase

v3.0.2

Published

FeathersJS DB adapter for couchbase

Readme

feathersjs-couchbase

Build Status Maintainability Test Coverage Dependencies Status Download Status

FeathersJS DB adapter for couchbase

Installation

npm install feathersjs-couchbase --save

Warning about N1QL Injections

This library only sanitizes values and does not sanitize any keys. It is a plan to build into the query builder a sanitization layer but for now it is open to attacks. This can be easily mitigated by validating your input and excluding any keys not expected from your input.

{
  "; SELECT * FROM `admin`; /*": "*/"
}

Documentation

const couchbase = require('couchbase')
const cluster = new couchbase.Cluster('couchbase://127.0.0.1')
const bucketName = 'default';
const bucket = cluster.openBucket(bucketName)

const config = {
  name: 'users', // Name of service and key prefix (REQUIRED)
  bucket: bucketName, // Couchbase bucket name (REQUIRED)
  connection: bucket, // Bucket connection, or promise that resolves to connection (REQUIRED)
  
  separator: '::' // optional key separator (defaults to `::`)
  couchbase: couchbase, // optional couchbase dependency (OPTIONAL)
  id: 'id', // ID field to use (OPTIONAL) (defaults to `uuid`)
  paginate: app.get('paginate'), // (OPTIONAL)
};

// Initialize our service with all options it requires
app.use(`/${options.name}`, new Service(options));
 
const createService = require('feathersjs-couchbase')
  
// Method 1
app.use('/',createService(config));
 
// Method 2
const { CouchService } = require('feathersjs-couchbase');
new CouchService(config)

Recommended Service Creation

'use strict';

const { CouchService } = require('feathersjs-couchbase');

class Users extends CouchService {
  constructor(opts){
    super(opts);
  }

  create(data, params){
    return super.create(
      Object.assign({ // Your default data here
        auth0Id: null,
        role: 'default',
      }, data) // Data passed in
    , params);
  }
}

module.exports = Rooms;

API

The library implements the full feathersjs common api and Query api, see limitations for exceptions.

Finds will not work until an index is built over the bucket you're trying to query

Additional API

$consistency (only valid on Service.find)

N1QL Consistency special parameter. Consistency Documentation

const { QueryConsistency } = require('feathersjs-couchbase');

Service.find({
  query: {
    $consistency: QueryConsistency.NOT_BOUNDED
    ... 
  }
});

Consistency Levels:

  • NOT_BOUNDED
  • REQUEST_PLUS
  • STATEMENT_PLUS

Omitting $consistency results in the default consistency of 'at_plus';

$return (only valid on Service.remove)

Due to the nature of removing items, you may want to retrieve the CAS value. Calling Service.remove(..., { $return: true }) will remove the entity and return the removed CAS value instead of the original object.

Limitations

  • Subqueries are not supported
  • Only tested with feathers v3
  • $selects on Service.find calls pulls all data and removes sections locally
  • Does not validate query logic, a query with a directive and value results in an invalid query ({ thing: { one: 1, $lt: 2 } }) --> thing.one = 1 AND thing < 2

License

Copyright (c) 2018

Licensed under the MIT license.

Contributing

Definitions

  • Directives - A directive as used in this project is a special query definition. An example of a directive would be $in, $limit, or $skip.

  • SingleValueDirective and FieldValueDirective are both directives (usually equality) that relate a singular value or a mapped field. A mapped field can either be a directive itself or a subvalue of a parent object.

query: {
  //Results in a FieldValueDirective that builds `top < $1`
  top: {
    $lt: 1
  },
  //Results in a FieldValueDirective that builds `sub.one = $2`
  sub: {
    one: 1
  }
}

Changelog

v3.0.1:

  • Fix service.find() queries
  • Update ramda

v3.0.0:

  • Remove dependency on unmaintained couchbase-promise library (couchbase > request > @hapi/hawk)

v2.5.0:

  • Error when incorrect query directives are provided at root level

v2.4.0:

  • Adds multi-access support to create function

v2.3.0:

  • Support for nested subobjects added. The following query results in one.two = 1
query: {
  one: {
    two: 1
  }
}

v2.2.0:

  • On service.remove the original object is returned by default.