@azure/cosmos has moved to a new repo https://github.com/Azure/azure-sdk-for-js
Перейти к файлу
Steve Faulkner 1281077a69 3.1.1 2019-08-07 09:30:47 -05: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 Fix changefeed sample 2019-07-16 16:02:32 -05:00
src Fix bug where offset limit iterator was being called for each item under the offset count (#398) 2019-08-07 09:30:21 -05:00
test Fix bug where offset limit iterator was being called for each item under the offset count (#398) 2019-08-07 09:30:21 -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 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 for v3 (#374) 2019-07-17 18:10:53 -05: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 Add junit reporter (#375) 2019-07-19 23:07:57 -05: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 (#208) 2018-12-13 13:19:13 -08:00
karma.config.js TypeScript conversion (#3) 2018-06-04 14:03:49 -07:00
package-lock.json 3.1.1 2019-08-07 09:30:47 -05:00
package.json 3.1.1 2019-08-07 09:30:47 -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

// 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.