Book Image

Learning Azure DocumentDB

By : Riccardo Becker
Book Image

Learning Azure DocumentDB

By: Riccardo Becker

Overview of this book

Learning DocumentDB adopts a practical, step-by-step approach to help you learn the basics of DocumentDB and use your new-found abilities in real-life scenarios and enterprise solutions. We start with the absolute basics, such as setting up a DocumentDB environment, and guide you through managing your databases, and executing simple and complex queries. Next, we explain how to work with DocumentDB using the open REST protocol, and demonstrate how JavaScript works with DocumentDB. We’ll also show you how to authenticate and execute queries. Moving on, you’ll find out how to use DocumentDB from within Node.js to kick-start your Node.js projects. Next, you’ll discover how to increase the performance of your DocumentDB database and fine-tune it. Finally, you’ll get to grips with using DocumentDB in conjunction with other services offered from the Microsoft Azure platform.
Table of Contents (15 chapters)
Learning Azure DocumentDB
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the SELECT statement


As we have seen in the previous chapters, the SELECT statement is the key to using DocumentDB and selecting, finding, and filtering resources inside your collections.

The SELECT statement is described in the following syntax convention:

<select_query> ::=
SELECT <select_specification> 
    [ FROM <from_specification>] 
    [ WHERE <filter_condition> ]
    [ ORDER BY <order_by_specification>]

As you can see, a SELECT statement consists of the SELECT keyword as well as (optionally) the FROM and WHERE clauses.

It is possible to execute only the SELECT statement, as we will see later in this chapter. The following code snippet shows a simple example of only a SELECT statement:

SELECT ABS(-1) returns 
 [
  {
    "$1": 1
  }
]

Selecting some documents

In the previous chapters, we performed some basic querying against our collections. The following snippet is a simple query that returns all the first names inside the collection (the one we used...