Socket
Book a DemoInstallSign in
Socket

loopback-connector-couchdb

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-connector-couchdb

LoopBack CouchDB Connector

latest
Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
9
50%
Maintainers
1
Weekly downloads
 
Created
Source

loopback-connector-couchdb

Build Status Coverage Status

What

A connector is used to connect Loopback models to a storage, and in this case, a CouchDB DB. See the official doc for Connecting models to data sources.

How to

Config

Example:

// server/datasources.json
{
  "lorem": {
    "name": "cache", // the datasource name
    "connector": "couchdb", // the connector name
    "url": "${couchdbUrl}", // optional
    "database": "lorem", // required
    "designDocs": {} // optional
  }
}

Install design docs

The designDocs that you put in the datasource config can be installed with autoupdate() or automigrate(). Example:

// server/datasources.json
{
  "lorem": {
    ...
    "designDocs": {
      "find": {
        "views": {
          "byName": {
            "map": "function(doc) { if (doc.name) emit(doc.name, null); }"
          }
        }
      }
    }
  }
}

Use a view

Example:

// Assuming you have a connector instance.
// Note that `connect()` returns a cached connection (singleton, promisified, wrapped in a Bluebird promise).
connector.connect().call('viewAsync', 'find', 'byName', { keys: ['Charlie'] }).then((res) => {
  res.should.be.Object();
  res.should.have.property('rows').which.is.Array().with.length(1);
});

See the tests for more examples.

Keywords

LoopBack

FAQs

Package last updated on 23 Feb 2017

Did you know?

Socket

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.

Install

Related posts