DocumentDB is Microsoft's own NoSQL database with an SQL-like query feature. When I say SQL-like, I mean it allows us to query the JSON documents using our all-time favorite SQL queries.
Before beginning with the queries, let's learn the basics of DocumentDB query.
Every DocumentDB query consists of a SELECT
statement and optional FROM
and WHERE
clauses as per ANSI-SQL standards.
For each query, the source in the FROM
clause is searched and traversed. Then the filter part in the WHERE
clause is applied on the source to retrieve a subset of JSON documents.
At the end, the SELECT
clause is used to populate the requested JSON values in the select list.
The order of the statements can be like the following:
SELECT <select_list> [FROM <from_specification>] [WHERE <filter_condition>][ORDER BY <sort_specification]
Let's begin with the query.