High-Level Introduction to Working with SODA for In-Database JavaScript

The SODA API is part of the MLE JavaScript SQL driver. Interaction with collections and documents requires you to establish a connection with the database first, before a SODA database object can be obtained.

The SODA database is the top-level abstraction object when working with the SODA API.

Figure 8-1 demonstrates the standard control flow.

Figure 8-1 SODA for In-Database JavaScript Basic Workflow



Applications that aren't ported from client-side Node.js or Deno can benefit from coding aids available in the MLE JavaScript SQL driver, such as a number of frequently used variables that are available in the global scope. For a complete list of available global variables and types, see Working with the MLE JavaScript Driver.

For SODA applications the most important global variable is the soda object, which represents the SodaDatabase object. The availability of the soda object in the global scope reduces the need for writing boilerplate code. In this case the workflow can be simplified, as in Figure 8-2.

Figure 8-2 SODA for In-Database JavaScript Simplified Workflow



Note:

If you are running your JavaScript code in a restricted execution context, you cannot use the SODA API. For more information about restricted execution contexts, see About Restricted Execution Contexts.