Search⌘ K
AI Features

Overview of Stored Procedures

Explore how to implement and use stored procedures in Azure Cosmos DB using JavaScript. Understand transactional scope, partition key requirements, document manipulation, and various ways to upload and execute stored procedures in server-side programming.

Introduction

Stored procedures are JavaScript functions that can run on the database engine when we manually request them, and unlike user-defined functions, they cannot be used in queries.

We can fully utilize the JavaScript API to interact with documents.

Note: All inputs are strings. If we need complex objects, we have to use JSON.parse.

Transactions

Stored procedures run in a transactional scope. All the changes are rolled back if any exception happens in the function. In Cosmos DB, transactions exist only within a logical partition, so we need to specify a partition key when we run a stored procedure. ...