Introduction to the JavaScript API

Get a brief introduction to what the JavaScript API offers in Cosmos DB when working on stored procedures or triggers.

Introduction

A valuable feature of Cosmos DB is its ability to run JavaScript code in its engine. When possible, it’s always advisable to use the SDKs. However, we can use the JavaScript API when we need more features or performance.

More specifically, we can use it in the following ways:

  • Stored procedures

  • Triggers

The context

Usually, the context is the most important instance when a function runs in the engine. We can get a reference to it with the getContext() method.

We can access the following using the context instance:

  • The container

  • The request

  • The response

Get hands-on with 1400+ tech skills courses.