Support of Azure Cosmos DB for Node.js

CAST supports Azure Cosmos DB via its com.castsoftware.nodejs extension. Details about how this support is provided for Node.js source code is discussed below.

Objects

Icon Description

Node.js Azure CosmosDB Database

Node.js Azure CosmosDB Collection

Node.js Azure CosmosDB Unknown Database

Node.js CosmosDB Unknown Collection

Detailed support

The @azure/cosmos package is supported. Whenever a container client use one of the method listed in the following table, a link is created to the corresponding collection.

LinkType Methods from Container Methods from Item Methods from Items
useDelete delete delete batch, bulk
useSelect - read, query batch, bulk, query, readAll
useUpdate - replace batch, bulk, upsert
useInsert - - batch, bulk, create

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.