Support of Azure Cosmos DB for Node.js


Objects

Icon Description
NodeJS CosmosDB Database
NodeJS CosmosDB Collection
NodeJS CosmosDB Unknown Database
NodeJS CosmosDB Unknown Collection

Supported libraries

Library require Versions
Azure Cosmos DB @azure/cosmos 3.x to 4.x
Link Type Supported APIs from
Container
Supported APIs from
Item
Supported APIs from
Items
useSelectLink read
query
batch
bulk
query
readAll
useInsertLink batch
bulk
create
useUpdateLink replace batch
bulk
upsert
useDeleteLink delete delete batch
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.