title | description | keywords | services | author | manager | editor | documentationcenter | ms.assetid | ms.service | ms.workload | ms.tgt_pltfrm | ms.devlang | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Node.js examples for Azure Cosmos DB | Microsoft Docs |
Find Node.js examples on github for common tasks in Azure Cosmos DB, including CRUD operations. |
node.js examples |
cosmos-db |
moderakh |
jhubbard |
monicar |
nodejs |
d87d97be-47a5-4928-8d46-a541fbb33213 |
cosmos-db |
data-services |
na |
na |
article |
05/23/2017 |
moderakh |
[!div class="op_single_selector"]
Sample solutions that perform CRUD operations and other common operations on Azure Cosmos DB resources are included in the azure-documentdb-nodejs GitHub repository. This article provides:
- Links to the tasks in each of the Node.js example project files.
- Links to the related API reference content.
Prerequisites
[!INCLUDE quickstarts-free-trial-note]
- You can activate Visual Studio subscriber benefits: Your Visual Studio subscription gives you credits every month that you can use for paid Azure services.
[!INCLUDE cosmos-db-emulator-docdb-api]
You also need the Node.js SDK.
Note
Each sample is self-contained, it sets itself up and cleans up after itself. As such, the samples issue multiple calls to DocumentClient.createCollection. Each time this is done your subscription will be billed for 1 hour of usage per the performance tier of the collection being created.
The app.js file of the DatabaseManagement project shows how to perform the following tasks.
The app.js file of the CollectionManagement project shows how to perform the following tasks.
The app.js file of the DocumentManagement project shows how to perform the following tasks.
The app.js file of the IndexManagement project shows how to perform the following tasks.
For more information about indexing, see Azure Cosmos DB indexing policies.
The app.js file of the ServerSideScripts project shows how to perform the following tasks.
Task | API reference |
---|---|
Create a stored procedure | DocumentClient.createStoredProcedure |
Execute a stored procedure | DocumentClient.executeStoredProcedure |
For more information about server-side programming, see Azure Cosmos DB server-side programming: Stored procedures, database triggers, and UDFs.
The app.js file of the Partitioning project shows how to perform the following tasks.
Task | API reference |
---|---|
Use a HashPartitionResolver | HashPartitionResolver |
For more information about partitioning data in Azure Cosmos DB, see Partition and scale data in Azure Cosmos DB.