Support of Azure Cosmos DB for Node.js


Objects

IconDescription
NodeJS CosmosDB Database
NodeJS CosmosDB Collection
NodeJS CosmosDB Unknown Database
NodeJS CosmosDB Unknown Collection

Supported libraries

LibraryrequireVersions
Azure Cosmos DB@azure/cosmos3.x to 4.x
Link TypeSupported APIs from
Container
Supported APIs from
Item
Supported APIs from
Items
useSelectLinkread
query
batch
bulk
query
readAll
useInsertLinkbatch
bulk
create
useUpdateLinkreplacebatch
bulk
upsert
useDeleteLinkdeletedeletebatch
bulk

Whenever a container client use one of the method listed in the following table, a link is created to the corresponding collection.

If the evaluation of the container name fails (either due to missing information in the source code or to limitations in the evaluation) a link is created to an Unknown collection.

What results can you expect?

When analyzing the following source code:

const CosmosClient = require("@azure/cosmos");
const client = new CosmosClient({ endpoint: endpoint, auth: { masterKey } });
const databaseId = 'My database'
const collectionId = 'My collection'

// CREATE DATABASE
const dbResponse = client.databases.createIfNotExists({
  id: databaseId
});
database = dbResponse.database;

// CREATE COLLECTION
const coResponse = database.containers.createIfNotExists({
  id: collectionId
});
container = coResponse.container;

// QUERY
var param = {
    query: "SELECT * FROM root r WHERE r.completed=@completed",
    parameters: [
        {
            name: '@completed',
            value: false
        }
    ]
};

const { result: results } = container.items
    .query(param)
    .toArray();

client.database(databaseId).delete()

you will get the following result:

Known Limitations

The link type for bulk and batch methods is not evaluated. All possible link types are created.