@azure/cosmos has moved to a new repo https://github.com/Azure/azure-sdk-for-js
Перейти к файлу
Steve Faulkner fafe4e2025 3.0.0-20 2019-06-21 17:50:30 -04:00
.vscode Refactor to Unified RequestContext (#272) 2019-03-27 22:51:45 -04:00
consumer-test Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00
samples Remove sproc upserts (#356) 2019-06-20 13:47:13 -07:00
src Parse connection string for options object (#350) 2019-06-21 17:44:16 -04:00
test Parse connection string for options object (#350) 2019-06-21 17:44:16 -04: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 Remove node builtin usage in favor of universal packages/APIs (#328) 2019-05-31 14:01:13 -04: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
README.md Remove AuthOptions (#339) 2019-06-11 16:19:24 -04:00
SDK + Samples Workspace.code-workspace TypeScript conversion (#3) 2018-06-04 14:03:49 -07:00
api-extractor.json Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00
azure-pipelines.yml Remove node builtin usage in favor of universal packages/APIs (#328) 2019-05-31 14:01:13 -04: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 2.0.1 (#143) 2018-09-24 18:26:17 -07:00
consumer-test.js Remove node builtin usage in favor of universal packages/APIs (#328) 2019-05-31 14:01:13 -04:00
dev.md Add multiregion guard for change feed tests (#209) 2018-12-13 13:19:06 -08:00
karma.config.js TypeScript conversion (#3) 2018-06-04 14:03:49 -07:00
package-lock.json 3.0.0-20 2019-06-21 17:50:30 -04:00
package.json 3.0.0-20 2019-06-21 17:50:30 -04:00
rollup.config.js Convert to TS project references. Extract test folder (#270) 2019-03-19 10:29:27 -07:00
tsconfig.json Typecheck Samples (#342) 2019-06-11 16:21:28 -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

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);
});

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.