Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.vscode [Cosmos] Cross Partition Group By (#5749) Oct 27, 2019
__snapshots__
consumer-test update repo structure as per central repo Aug 13, 2019
review Update cosmos.api.md (#6454) Dec 6, 2019
samples
src [Cosmos] Fix handling of special characters in the browser (#6379) Dec 3, 2019
test [Cosmos] Improve error for mixed type orderby (#6306) Nov 23, 2019
.editorConfig update repo structure as per central repo Aug 13, 2019
.eslintrc.json [Cosmos] Import `eslint-plugin-azure-sdk` plugin and run `lint:fix` (#… Sep 19, 2019
.gitignore
.prettierignore
.travis.yml update repo structure as per central repo Aug 13, 2019
Contributing.md update repo structure as per central repo Aug 13, 2019
LICENSE
PoliCheckExclusions.txt update repo structure as per central repo Aug 13, 2019
README.md Update impressions (#5977) Nov 5, 2019
SDK + Samples Workspace.code-workspace
api-extractor.json
azure-pipelines.yml Update to powershell, and add retries to Invoke-WebRequest (#5268) Sep 26, 2019
browser-test.js [Cosmos] format files using prettier - rushx format (#5142) Sep 16, 2019
bundle-types.js [Cosmos] format files using prettier - rushx format (#5142) Sep 16, 2019
changelog.md
consumer-test.js [Cosmos] Update execa and universal-user-agent to latest version (#5148) Sep 19, 2019
dev.md
karma.config.js [Cosmos] format files using prettier - rushx format (#5142) Sep 16, 2019
package.json [Cosmos] 3.5.2 (#6385) Dec 3, 2019
rollup.config.js [Cosmos] Remove universal-user-agent (#5869) Oct 28, 2019
tsconfig.json update repo structure as per central repo Aug 13, 2019
tslint.json [Cosmos] Cross Partition Group By (#5749) Oct 27, 2019
writeSDKVersion.js update repo structure as per central repo Aug 13, 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.

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

You can’t perform that action at this time.