JSPM

@azure/cosmos

3.6.1-dev.20200218.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 525472
  • Score
    100M100P100Q227067F
  • License MIT

Microsoft Azure Cosmos DB Service Node.js SDK for SQL API

Package Exports

  • @azure/cosmos
  • @azure/cosmos/dist-esm/request/defaultAgent.browser.js
  • @azure/cosmos/dist-esm/request/defaultAgent.js
  • @azure/cosmos/dist-esm/utils/atob.browser.js
  • @azure/cosmos/dist-esm/utils/atob.js
  • @azure/cosmos/dist-esm/utils/digest.browser.js
  • @azure/cosmos/dist-esm/utils/digest.js
  • @azure/cosmos/dist-esm/utils/hmac.browser.js
  • @azure/cosmos/dist-esm/utils/hmac.js
  • @azure/cosmos/dist-esm/utils/user-agent.browser.js
  • @azure/cosmos/dist-esm/utils/user-agent.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@azure/cosmos) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Microsoft Azure Cosmos JavaScript SDK

This project provides JavaScript & Node.js SDK library for SQL API of Azure Cosmos Database Service. This project also includes samples, tools, and utilities.

latest npm badge Build Status

// JavaScript
const { CosmosClient } = require("@azure/cosmos");

const endpoint = "https://your-account.documents.azure.com"; // Add your endpoint
const key = "[database account masterkey]"; // Add the masterkey of the endpoint
const client = new CosmosClient({ endpoint, key });

const databaseDefinition = { id: "sample database" };
const collectionDefinition = { id: "sample collection" };
const documentDefinition = { id: "hello world doc", content: "Hello World!" };

async function helloCosmos() {
  const { database } = await client.databases.create(databaseDefinition);
  console.log("created database");

  const { container } = await database.containers.create(collectionDefinition);
  console.log("created collection");

  const { resource } = await container.items.create(documentDefinition);
  console.log("Created item with content: ", resource.content);

  await database.delete();
  console.log("Deleted database");
}

helloCosmos().catch((err) => {
  console.error(err);
});

Install via NPM

You can install the npm package using the following command:

npm install @azure/cosmos

Need Help?

Tweet us with #CosmosDB and we'll respond on Twitter. Be sure to check out the Microsoft Azure Developer Forums on MSDN or the Developer Forums on Stack Overflow if you have trouble with the provided code.

Contribute Code or Provide Feedback

For our rules and guidelines on contributing, please see Microsoft's contributor guide.

For information on how build and test this repo, please see ./dev.md.

If you encounter any bugs with the library please file an issue in the Issues section of the project.

Impressions