The internal data model described in the previous section is exposed through: • a proprietary SQL API. • five different compatibility APIs, exposing endpoints that are partially compatible with the wire protocols of
MongoDB,
Gremlin,
Cassandra, Azure Table Storage, and
etcd; these compatibility APIs make it possible for any compatible application to connect to and use Cosmos DB through standard drivers or SDKs, while also benefiting from Cosmos DB's core features like partitioning and global distribution.
SQL API The SQL API lets clients create, update and delete containers and items. Items can be queried with a read-only,
JSON-friendly SQL dialect. As Cosmos DB embeds a
JavaScript engine, the SQL API also enables: •
Stored procedures. Functions that bundle an arbitrarily complex set of operations and logic into an
ACID-compliant transaction. They are isolated from changes made while the stored procedure is executing and either all write operations succeed or they all fail, leaving the database in a consistent state. Stored procedures are executed in a single partition. Therefore, the caller must provide a partition key when calling into a partitioned collection. Stored procedures can be used to make up for the lack of certain functionality. For instance, the lack of aggregation capability is made up for by the implementation of an
OLAP cube as a stored procedure in the open sourced documentdb-lumenize project. •
Triggers. Functions that get executed before or after specific operations (like on a document insertion for example) that can either alter the operation or cancel it. Triggers are only executed on request. •
User-defined functions (UDF). Functions that can be called from and augment the SQL query language making up for limited SQL features. The SQL API is exposed as a
REST API, which itself is implemented in various SDKs that are officially supported by Microsoft and available for
.NET Framework,
.NET,
Node.js (
JavaScript),
Java and
Python. == Partitioning ==