Gathering detailed insights and metrics for loopback-connector-uo-cloudant
Gathering detailed insights and metrics for loopback-connector-uo-cloudant
npm install loopback-connector-uo-cloudant
Typescript
Module System
Node Version
NPM Version
48.9
Supply Chain
83.1
Quality
67.5
Maintenance
25
Vulnerability
89.6
License
Total Downloads
10,301
Last Day
1
Last Week
2
Last Month
161
Last Year
5,399
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
loopback-connector-uo-cloudant@1.0.0
Unpacked Size
44.97 kB
Size
13.19 kB
File Count
20
NPM Version
6.9.0
Node Version
10.16.2
Cumulative downloads
Total Downloads
Last day
-75%
1
Compared to previous day
Last week
-96.2%
2
Compared to previous week
Last month
12.6%
161
Compared to previous month
Last year
46.4%
5,399
Compared to previous year
Cloudant DB connector for the StrongLoop Loopback framework.
Please see the full documentation at loopback.io
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.
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.
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
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' |
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,
...
"cloudant": {
"modelIndex": "custom_doc_type_property_name",
"modelSelector": { "doc_type": "user" },
"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'. |
modelSelector | JSON | Use the Cloudant Query selector syntax to associate models to existing data. modelSelector and modelIndex are mutually exclusive. https://docs.cloudant.com/cloudant_query.html#selector-syntax |
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: "tony@t.com"
}, function (err, user) {
console.log (user);
});
User.find ({ where: { name: "Tony" }}, function (err, users) {
console.log (users);
});
User.destroyAll (function () {
console.log ('test complete');
})
There is no free version of local Cloudant to download, so to develop or test with cloudant connector, users can setup their instance in two ways:
Choose bluemix Cloudant if you already have a bluemix account with a better situation than limited-days' free trial.
Setup steps:
For cloudant on both DBaaS and Bluemix, to get access to the cloudant dashboard, you can sign in https://cloudant.com/sign-in/ with your cloudant username and password.
After having Cloudant instance, you will need three config properties to run the tests: username
, password
, database
To run the tests:
CLOUDANT_USERNAME=username CLOUDANT_PASSWORD=password CLOUDANT_DATABASE=database npm test
No vulnerabilities found.
No security vulnerabilities found.