Socket
Socket
Sign inDemoInstall

@ibm-cloud/cloudant

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ibm-cloud/cloudant - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

4

package.json
{
"name": "@ibm-cloud/cloudant",
"version": "0.0.11",
"version": "0.0.12",
"description": "IBM Cloudant Node.js SDK",

@@ -40,3 +40,3 @@ "main": "index.js",

"dependencies": {
"@types/node": "^12.0.8",
"@types/node": "^14.14.7",
"extend": "^3.0.2",

@@ -43,0 +43,0 @@ "ibm-cloud-sdk-core": "~2.7.0"

<!--
The example codes and outputs below are generated using the `embedmd` go package.
The example codes and outputs below are generated using the `embedmd` go
package.
https://github.com/campoy/embedmd
You should regenerate the example codes after making any changes to examples in the test/examples/ folder.
You should regenerate the example codes after making any changes to
examples in the test/examples/ folder.

@@ -12,9 +14,5 @@ embedmd -w README.md

[![Build Status](https://travis-ci.com/IBM/cloudant-node-sdk.svg?branch=master)](https://travis-ci.com/IBM/cloudant-node-sdk)
<!--
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![npm-version](https://img.shields.io/npm/v/IBM/cloudant-node-sdk.svg)](https://www.npmjs.com/package/@ibmcloud/cloudant)
[![codecov](https://codecov.io/gh/IBM/cloudant-node-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/IBM/cloudant-node-sdk)
-->
[![Release](https://img.shields.io/github/v/release/IBM/cloudant-node-sdk?include_prereleases&sort=semver)](https://github.com/IBM/cloudant-node-sdk/releases/latest)
# IBM Cloudant Node.js SDK Version 0.0.11
# IBM Cloudant Node.js SDK Version 0.0.12

@@ -47,18 +45,19 @@ Node.js client library to interact with the

- [Authentication](#authentication)
* [Authenticate with environment variables](#authenticate-with-environment-variables)
* [Authentication with environment variables](#authentication-with-environment-variables)
+ [IAM authentication](#iam-authentication)
+ [Session cookie authentication](#session-cookie-authentication)
+ [Basic authentication](#basic-authentication)
* [Authenticate with external configuration](#authenticate-with-external-configuration)
* [Authenticate programmatically](#authenticate-programmatically)
- [Code examples](#code-examples)
* [1. Retrieve information from an existing database](#1-retrieve-information-from-an-existing-database)
* [2. Create your own database and add a document](#2-create-your-own-database-and-add-a-document)
* [3. Update your previously created document](#3-update-your-previously-created-document)
* [4. Delete your previously created document](#4-delete-your-previously-created-document)
- [Error handling](#error-handling)
* [Authentication with external configuration](#authentication-with-external-configuration)
* [Programmatic authentication](#programmatic-authentication)
- [Using the SDK](#using-the-sdk)
* [Code examples](#code-examples)
+ [1. Retrieve information from an existing database](#1-retrieve-information-from-an-existing-database)
+ [2. Create your own database and add a document](#2-create-your-own-database-and-add-a-document)
+ [3. Update your previously created document](#3-update-your-previously-created-document)
+ [4. Delete your previously created document](#4-delete-your-previously-created-document)
* [Error handling](#error-handling)
* [Raw IO](#raw-io)
* [Further resources](#further-resources)
- [Questions](#questions)
- [Issues](#issues)
- [Further resources](#further-resources)
- [Open source @ IBM](#open-source--ibm)

@@ -82,3 +81,2 @@ - [Contributing](#contributing)

provided by Cloudant and supply other functions to ease the usage of Cloudant.
Moreover, it has limited support for CouchDB as well.
This SDK should make life easier for programmers to do what’s really important

@@ -91,2 +89,6 @@ for them: develop.

- Supported by IBM Cloudant.
- Server compatibility with:
- IBM Cloudant "Classic"
- [Cloudant "Standard on Transaction Engine"](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-overview-te) for APIs compatible with Cloudant "Classic" (see the [Feature Parity page](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-overview-te#feature-parity-between-ibm-cloudant-on-the-transaction-engine-vs-classic-architecture) for further details).
- [Apache CouchDB 3.x](https://docs.couchdb.org/en/stable/) for data operations
- Includes all the most popular and latest supported endpoints for

@@ -96,2 +98,3 @@ applications.

- Familiar user experience of IBM Cloud SDKs.
- Flexibility to use either built-in models or byte-based requests and responses for documents.
- `Promise` based design with asynchronous HTTP requests.

@@ -103,11 +106,10 @@ - Use either as native JavaScript or take advantage of TypeScript models.

[ibm-cloud-onboarding]: http://cloud.ibm.com/registration
- You need an [IBM Cloud][ibm-cloud-onboarding] account.
- An IAM API key to allow the SDK to access your account.
Create one [here](https://cloud.ibm.com/iam/apikeys).
- A
[Cloudant](https://cloud.ibm.com/docs/Cloudant/getting-started.html#step-1-connect-to-your-cloudant-nosql-db-service-instance-on-ibm-cloud)
service instance or a
[CouchDB](https://docs.couchdb.org/en/latest/install/index.html)
server.
- **Node.js 10, 12, 14**: This SDK is tested with Node.js versions 10, 12, and 14.
It may work on other versions but those are not officially supported.
## Installation

@@ -136,3 +138,4 @@

authentication type requires a server-generated `apikey` instead of a
user-given password.
user-given password. You can create one
[here](https://cloud.ibm.com/iam/apikeys).
1. [*Session cookie (`COUCHDB_SESSION`) authentication*](#session-cookie-authentication)

@@ -154,7 +157,7 @@ is recommended for [Apache CouchDB][couch-cookie-auth] or for

1. As [environment variables](#authenticate-with-environment-variables)
1. The [programmatic approach](#authenticate-programmatically)
1. With an [external credentials file](#authenticate-with-external-configuration)
1. As [environment variables](#authentication-with-environment-variables)
1. The [programmatic approach](#programmatic-authentication)
1. With an [external credentials file](#authentication-with-external-configuration)
### Authenticate with environment variables
### Authentication with environment variables

@@ -202,3 +205,3 @@ #### IAM authentication

### Authenticate with external configuration
### Authentication with external configuration

@@ -211,3 +214,3 @@ To use an external configuration file, the

### Authenticate programmatically
### Programmatic authentication

@@ -220,9 +223,16 @@ To learn more about how to use programmatic authentication, see the related

## Code examples
## Using the SDK
For general IBM Cloud SDK usage information, please see
[IBM Cloud SDK Common](https://github.com/IBM/ibm-cloud-sdk-common/blob/master/README.md).
### Code examples
The code examples below will follow the
[authentication with environment variables](#authenticate-with-environment-variables).
### 1. Retrieve information from an existing database
#### 1. Retrieve information from an existing database
**Note:** this example code assumes that `animaldb` database does not exist in your account.
This example code gathers some information about an existing database hosted on

@@ -245,2 +255,5 @@ the https://examples.cloudant.com/ service `url`. To do this, you need to

```ts
import {CloudantV1} from "@ibm-cloud/cloudant";
```
[embedmd]:# (test/examples/src/ts/GetInfoFromExistingDatabase.ts /\/\/ 1./ $)

@@ -292,2 +305,5 @@ ```ts

```js
const { CloudantV1 } = require('@ibm-cloud/cloudant');
```
[embedmd]:# (test/examples/src/js/GetInfoFromExistingDatabase.js /const getInfoFromExistingDatabase/ /getInfoFromExistingDatabase\(\);\n\}/)

@@ -335,3 +351,2 @@ ```js

The result of the code is similar to the following output.
The order of the output lines may change due to the asynchronicity.

@@ -356,4 +371,6 @@ [embedmd]:# (test/examples/output/GetInfoFromExistingDatabase.txt)

### 2. Create your own database and add a document
#### 2. Create your own database and add a document
**Note:** this example code assumes that `orders` database does not exist in your account.
Now comes the exciting part of creating your own `orders` database and adding

@@ -363,5 +380,11 @@ a document about *Bob Smith* with your own [IAM](#iam-authentication) or

<details>
<summary>Create code example</summary>
<details open>
<summary>TypeScript:</summary>
```ts
import {CloudantV1} from "@ibm-cloud/cloudant";
```
[embedmd]:# (test/examples/src/ts/CreateDbAndDoc.ts /interface/ $)

@@ -407,32 +430,15 @@ ```ts

/* Try to get the document and set revision of exampleDocument to the
latest one if it previously existed in the database */
// Save the document in the database
createDb.then(() => {
client.getDocument({db: exampleDbName, docId: exampleDocId})
.then(documentInfo => {
exampleDocument._rev = documentInfo.result._rev;
console.log("The document revision for" + exampleDocId +
"is set to " + exampleDocument._rev);
})
.catch(err => {
if (err.code === 404) {
// Document does not exist in database
}
})
.finally(() => {
// Save the document in the database
client.postDocument({
db: exampleDbName,
document: exampleDocument
}
).then(createDocumentResponse => {
// Keep track with the revision number of the document object
exampleDocument._rev = createDocumentResponse.result.rev;
console.log("You have created the document:\n" +
JSON.stringify(exampleDocument, null, 2));
});
});
client.postDocument({
db: exampleDbName,
document: exampleDocument
}).then(createDocumentResponse => {
// Keep track with the revision number of the document object
exampleDocument._rev = createDocumentResponse.result.rev;
console.log("You have created the document:\n" +
JSON.stringify(exampleDocument, null, 2));
});
});
```
</details>

@@ -443,2 +449,5 @@

```js
const { CloudantV1 } = require('@ibm-cloud/cloudant');
```
[embedmd]:# (test/examples/src/js/CreateDbAndDoc.js /const createDbAndDoc/ /createDbAndDoc\(\);\n\}/)

@@ -479,29 +488,11 @@ ```js

/* Try to get the document and set revision of exampleDocument to the
latest one if it previously existed in the database */
try {
exampleDocument._rev = (
await client.getDocument({
db: exampleDbName,
docId: exampleDocId,
})
).result._rev;
console.log(
'The document revision for "' + exampleDocId + '" is set to ' + exampleDocument._rev
);
} catch (err) {
if (err.code === 404) {
// Document does not exist in database
}
} finally {
// Save the document in the database
const createDocumentResponse = await client.postDocument({
db: exampleDbName,
document: exampleDocument,
});
// Save the document in the database
const createDocumentResponse = await client.postDocument({
db: exampleDbName,
document: exampleDocument,
});
// Keep track with the revision number of the document object
exampleDocument._rev = createDocumentResponse.result.rev;
console.log('You have created the document:\n' + JSON.stringify(exampleDocument, null, 2));
}
// Keep track with the revision number of the document object
exampleDocument._rev = createDocumentResponse.result.rev;
console.log('You have created the document:\n' + JSON.stringify(exampleDocument, null, 2));
};

@@ -513,7 +504,7 @@

```
</details>
</details>
The result of the code is similar to the following output.
The order of the output lines may change due to the asynchronicity.

@@ -532,3 +523,3 @@ [embedmd]:# (test/examples/output/CreateDbAndDoc.txt)

### 3. Update your previously created document
#### 3. Update your previously created document

@@ -541,5 +532,11 @@ **Note**: this example code assumes that you have created both the `orders`

<details>
<summary>Update code example</summary>
<details open>
<summary>TypeScript:</summary>
```ts
import {CloudantV1} from "@ibm-cloud/cloudant";
```
[embedmd]:# (test/examples/src/ts/UpdateDoc.ts /interface/ $)

@@ -594,3 +591,2 @@ ```ts

```
</details>

@@ -601,2 +597,5 @@

```js
const { CloudantV1 } = require('@ibm-cloud/cloudant');
```
[embedmd]:# (test/examples/src/js/UpdateDoc.js /const updateDoc/ /updateDoc\(\);\n\}/)

@@ -651,5 +650,6 @@ ```js

```
</details>
</details>
The result of the code is similar to the following output.

@@ -662,3 +662,3 @@

"_id": "example",
"_rev": "2-70476cf75eb02f55c6c4061aa6941ec8",
"_rev": "2-4e2178e85cffb32d38ba4e451f6ca376",
"name": "Bob Smith",

@@ -669,3 +669,3 @@ "address": "19 Front Street, Darlington, DL5 1TY"

### 4. Delete your previously created document
#### 4. Delete your previously created document

@@ -678,5 +678,11 @@ **Note**: this example code assumes that you have created both the `orders`

<details>
<summary>Delete code example</summary>
<details open>
<summary>TypeScript:</summary>
```ts
import {CloudantV1} from "@ibm-cloud/cloudant";
```
[embedmd]:# (test/examples/src/ts/DeleteDoc.ts /interface/ $)

@@ -725,3 +731,2 @@ ```ts

```
</details>

@@ -732,2 +737,5 @@

```js
const { CloudantV1 } = require('@ibm-cloud/cloudant');
```
[embedmd]:# (test/examples/src/js/DeleteDoc.js /const deleteDoc/ /deleteDoc\(\);\n\}/)

@@ -775,5 +783,6 @@ ```js

```
</details>
</details>
The result of the code is the following output.

@@ -786,3 +795,3 @@

## Error handling
### Error handling

@@ -792,22 +801,15 @@ For sample code on handling errors, please see

## Using the SDK
### Raw IO
For general SDK usage information, please see
[this link](https://github.com/IBM/ibm-cloud-sdk-common/blob/master/README.md).
For endpoints that read or write document content it is possible to bypass
usage of the built-in models and send or receive a bytes response.
For examples of using byte streams, see the API reference documentation
("Example request as a stream" section).
## Questions
- [Bulk modify multiple documents in a database](https://cloud.ibm.com/apidocs/cloudant?code=node#postbulkdocs)
- [Query a list of all documents in a database](https://cloud.ibm.com/apidocs/cloudant?code=node#postalldocs)
- [Query the database document changes feed](https://cloud.ibm.com/apidocs/cloudant?code=node#postchanges)
If you are having difficulties using this SDK or have a question about
the IBM Cloud services, please ask a question on
[Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-cloud).
### Further resources
## Issues
If you encounter an issue with the SDK, you are welcome to submit
a [bug report](https://github.com/IBM/cloudant-node-sdk/issues).
Before that, please search for similar issues. It's possible someone has
already encountered this issue.
## Further resources
- [Cloudant API docs](https://cloud.ibm.com/apidocs/cloudant?code=node):

@@ -823,2 +825,15 @@ API examples for Cloudant Node.js SDK.

## Questions
If you are having difficulties using this SDK or have a question about the
IBM Cloud services, please ask a question on
[Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-cloud).
## Issues
If you encounter an issue with the project, you are welcome to submit a
[bug report](https://github.com/IBM/cloudant-node-sdk/issues).
Before that, please search for similar issues. It's possible that someone
has already reported the problem.
## Open source @ IBM

@@ -825,0 +840,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc