@azure/cosmos has moved to a new repo https://github.com/Azure/azure-sdk-for-js
Перейти к файлу
Steve Faulkner 209ed5de3d 3.0.3 2019-07-17 15:04:13 -05:00
.vscode Fix merge conflicts with master 2019-07-16 14:38:48 -05:00
consumer-test
samples Fix changefeed sample 2019-07-16 16:02:32 -05:00
src Prevent webpack from resolving modules called with `require` (#373) 2019-07-17 14:57:29 -05:00
test Fix offer test 2019-07-16 15:25:57 -05:00
.editorConfig
.gitattributes
.gitignore Fix merge conflicts with master 2019-07-16 14:38:48 -05:00
.npmignore
.prettierignore
.prettierrc.json
.travis.yml
Contributing.md
LICENSE
PoliCheckExclusions.txt
README.md Fix merge conflicts with master 2019-07-16 14:38:48 -05:00
SDK + Samples Workspace.code-workspace
api-extractor.json
azure-pipelines.yml
browser-test.js
bundle-types.js
changelog.md Add v3 changelog and migration guide (#369) 2019-07-16 14:26:50 -05:00
consumer-test.js
dev.md
karma.config.js
package-lock.json 3.0.3 2019-07-17 15:04:13 -05:00
package.json 3.0.3 2019-07-17 15:04:13 -05:00
rollup.config.js
tsconfig.json
tslint.json
writeSDKVersion.js

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 Build Status

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

const endpoint = "[hostendpoint]"; // Add your endpoint
const masterKey = "[database account masterkey]"; // Add the masterkey of the endpoint
const client = new CosmosClient({ endpoint, key: masterKey });

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

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

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

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

  await db.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].(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.