GithubHelp home page GithubHelp logo

isabella232 / loopback-connector-couchdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wiredcraft/loopback-connector-couchdb

0.0 0.0 0.0 24 KB

License: MIT License

Makefile 2.03% JavaScript 97.97%

loopback-connector-couchdb's Introduction

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.

loopback-connector-couchdb's People

Contributors

fraserxu avatar makara avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.