Skip to content
JavaScript and Node.js library for Azure Cosmos DB
TypeScript JavaScript
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Add stale issue action (#415) Aug 23, 2019
.vscode Add retry on EPIPE error (#400) Aug 7, 2019
consumer-test Convert to TS project references. Extract test folder (#270) Mar 19, 2019
samples Add sample for bulk update with continuation token (#402) Aug 20, 2019
src Fix missing AbortSignal type for users not targeting the DOM (#416) Aug 23, 2019
test resolve credscan warnings (#414) Aug 20, 2019
.editorConfig Match EditorConfig with Prettier rules (#165) Oct 26, 2018
.gitattributes adding .git* Aug 26, 2014
.gitignore Fix merge conflicts with master Jul 16, 2019
.npmignore Update npmignore Mar 22, 2019
.prettierignore Convert to TS project references. Extract test folder (#270) Mar 19, 2019
.prettierrc.json Convert to TS project references. Extract test folder (#270) Mar 19, 2019
.travis.yml TS Consumer Smoke Test (#199) Nov 30, 2018
Contributing.md Node.js SDK Release 1.7.0 Apr 26, 2016
LICENSE TypeScript conversion (#3) Jun 4, 2018
PoliCheckExclusions.txt Add PolicheckExclusions.txt (#253) Mar 8, 2019
README.md Update README for v3 (#374) Jul 17, 2019
SDK + Samples Workspace.code-workspace TypeScript conversion (#3) Jun 4, 2018
api-extractor.json Convert to TS project references. Extract test folder (#270) Mar 19, 2019
azure-pipelines.yml Update azure-pipelines.yml for Azure Pipelines (#419) Aug 23, 2019
browser-test.js TypeScript conversion (#3) Jun 4, 2018
bundle-types.js ES module interop fixes; use rollup for production builds (#104) Dec 14, 2018
changelog.md resolve credscan warnings (#414) Aug 20, 2019
consumer-test.js Fix missing AbortSignal type for users not targeting the DOM (#416) Aug 23, 2019
dev.md Update Node.js version recommendation in dev.md (#418) Aug 22, 2019
karma.config.js TypeScript conversion (#3) Jun 4, 2018
package-lock.json bump typedoc dependency (#412) Aug 20, 2019
package.json bump typedoc dependency (#412) Aug 20, 2019
rollup.config.js Convert to TS project references. Extract test folder (#270) Mar 19, 2019
tsconfig.json Updating samples (#353) Jun 24, 2019
tslint.json Enable no-unecessary-class (v3) (#211) Dec 19, 2018
writeSDKVersion.js Convert to TS project references. Extract test folder (#270) Mar 19, 2019

README.md

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

Useful links

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].(https://docs.microsoft.com/en-us/contribute/).

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.

You can’t perform that action at this time.