@azure/cosmos has moved to a new repo https://github.com/Azure/azure-sdk-for-js
Перейти к файлу
microsoft-github-policy-service[bot] 240891b17c
Microsoft mandatory file
2023-01-24 16:40:07 +00:00
.github/ISSUE_TEMPLATE Update issue templates 2020-01-08 12:29:44 -06:00
.vscode Add retry on EPIPE error (#400) 2019-08-07 09:05:34 -05:00
consumer-test Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00
samples Add sample for bulk update with continuation token (#402) 2019-08-20 14:15:57 -05:00
src Fix missing AbortSignal type for users not targeting the DOM (#416) 2019-08-23 14:01:58 -05:00
test resolve credscan warnings (#414) 2019-08-20 14:55:22 -07:00
.editorConfig Match EditorConfig with Prettier rules (#165) 2018-10-26 10:40:46 -06:00
.gitattributes adding .git* 2014-08-26 08:25:08 -07:00
.gitignore Fix merge conflicts with master 2019-07-16 14:38:48 -05:00
.npmignore Update npmignore 2019-03-21 23:10:11 -07:00
.prettierignore Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00
.prettierrc.json Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00
.travis.yml TS Consumer Smoke Test (#199) 2018-11-30 15:13:40 -05:00
Contributing.md Node.js SDK Release 1.7.0 2016-04-26 13:21:42 -07:00
LICENSE TypeScript conversion (#3) 2018-06-04 14:03:49 -07:00
PoliCheckExclusions.txt Add PolicheckExclusions.txt (#253) 2019-03-08 17:39:10 -05:00
README.md Update README.md 2019-11-07 19:10:31 -06:00
SDK + Samples Workspace.code-workspace TypeScript conversion (#3) 2018-06-04 14:03:49 -07:00
SECURITY.md Microsoft mandatory file 2023-01-24 16:40:07 +00:00
api-extractor.json Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00
azure-pipelines.yml Update azure-pipelines.yml for Azure Pipelines (#419) 2019-08-23 11:09:11 -07:00
browser-test.js TypeScript conversion (#3) 2018-06-04 14:03:49 -07:00
bundle-types.js ES module interop fixes; use rollup for production builds (#104) 2018-12-14 08:12:55 -05:00
changelog.md resolve credscan warnings (#414) 2019-08-20 14:55:22 -07:00
consumer-test.js Fix missing AbortSignal type for users not targeting the DOM (#416) 2019-08-23 14:01:58 -05:00
dev.md Update Node.js version recommendation in dev.md (#418) 2019-08-22 16:58:22 -05:00
karma.config.js TypeScript conversion (#3) 2018-06-04 14:03:49 -07:00
package-lock.json 3.2.0 2019-08-26 10:58:15 -05:00
package.json 3.2.0 2019-08-26 10:58:15 -05:00
rollup.config.js Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00
tsconfig.json Updating samples (#353) 2019-06-24 17:44:19 -04:00
tslint.json Enable no-unecessary-class (v3) (#211) 2018-12-18 20:25:59 -05:00
writeSDKVersion.js Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00

README.md

🚨This SDK is now maintained at https://github.com/Azure/azure-sdk-for-js 🚨

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