@azure/cosmos has moved to a new repo https://github.com/Azure/azure-sdk-for-js
Перейти к файлу
Steve Faulkner 1d3a355bc2
Add v3 changelog and migration guide (#369)
* Add v3 changelog and migration guide

* Update changelog.md
2019-07-16 14:26:50 -05: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 Updating samples (#353) 2019-06-24 17:44:19 -04:00
src js docs cleanup (#367) 2019-07-16 12:05:03 -07:00
test Fix Aggregate Request Charge (#366) 2019-07-09 14:50:54 -05: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 Updating samples (#353) 2019-06-24 17:44:19 -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 Add v3 changelog and migration guide (#369) 2019-07-16 14:26:50 -05: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 js docs cleanup (#367) 2019-07-16 12:05:03 -07:00
package.json 3.0.2 2019-07-09 15:01:17 -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

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.