GithubHelp home page GithubHelp logo

samze / loopback-connector-cloudant Goto Github PK

View Code? Open in Web Editor NEW

This project forked from loopbackio/loopback-connector-cloudant

0.0 2.0 0.0 23 KB

LoopBack Connector for IBM Cloudant

License: Other

Makefile 1.31% JavaScript 98.69%

loopback-connector-cloudant's Introduction

loopback-connector-cloudant

Cloudant DB connector for the StrongLoop Loopback framework.

Please see the full documentation at docs.strongloop.com

Key Features

  • Uses Cloudant Query (Lucene) to support ad-hoc searching
  • Loopback Query support for: fields, limit, order, skip and where filters
  • Query and filtering is performed on the database for optimal efficiency
  • Use different DB instances per Model definition
  • Support basic Model discovery

LoopBack Connectors

LoopBack provides connectors for popular relational and NoSQL databases. These connectors implement CRUD operations as a common set of methods across different databases and allow quick and easy API creation for new or existing datasources.

More Info>>

IBM Cloudant

IBM Cloudant® is a NoSQL database platform built for the cloud. You can use Cloudant as a fully-managed DBaaS running on public cloud platforms like Bluemix, SoftLayer or via an on-premise version called Cloudant Local.

More Info>>

Install

To install the connector cd into the top level directory of your loopback application, enter:

$ npm install loopback-connector-cloudant --save

The --save options automatically as the dependency to the package.json file

Configuring the Cloudant datasource

Use the Data source generator to add the Cloudant data source to your application. The entry in the applications /server/datasources.json will look something like this:

"mydb": {
  "name": "mydb",
  "connector": "cloudant",
  "username": "XXXX-bluemix",
  "password": "YYYYYYYYYYYY",
  "database": "test"
}

Edit the datasources.json to add other supported properties as required:

Property Type Description
database String Database name
username String Cloudant username, use either 'url' or username/password
password String Cloudant password
url String Cloudant URL containing both username and password
modelIndex String Specify the model name to document mapping, defaults to 'loopback__model__name'

Model Specific Configuration

Per Model configuration is also supported for database selection and to specify different Loopback Model to document mappings:

common/models/<model_name>.json

{
  "name": "User",
  "base": "PersistedModel",
  "idInjection": true,
  ...
  "settings": {
    "cloudant": {
        "modelIndex": "myPropertyName",
        "database": "test2"
    }
  },
  ...

Model specific configuration settings:

Property Type Description
database String Database name
modelIndex String Specify the model name to document mapping, defaults to 'loopback__model__name'

Example Usage

var DataSource = require ('loopback-datasource-juggler').DataSource,
    Cloudant   = require ('loopback-connector-cloudant');

var config = {
    username: 'XXXXX-bluemix',
    password: 'YYYYYYYYYYYYY',
    database: 'test'
};

var db = new DataSource (Cloudant, config);

User = db.define ('User', {
  name: { type: String },
  email: { type: String }
});

User.create ({
  name: "Tony",
  email: "[email protected]"
}, function (err, user) {
  console.log (user);
});

User.find ({ where: { name: "Tony" }}, function (err, users) {
  console.log (users);
});

User.destroyAll (function () {
  console.log ('test complete');
})

Feature Backlog

  • Index only Model properties marked with index=true
  • Configurable "view based" or JSON indexes. More Info>>

loopback-connector-cloudant's People

Watchers

Sam Gunaratne avatar James Cloos 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.