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 FROM clause


The FROM clause is an optional clause, unless you want to apply filtering (by using the WHERE clause). The WHERE clause is used to specify the source(s) upon which the query needs to be executed. Mostly, the WHERE clause is used to select a collection. The FROM clause is needed when you want to query a collection.

Another example of using the SELECT statement without the FROM clause is the following code snippet:

SELECT CONTAINS(UPPER("Riccardo"), UPPER("ri"))

This SELECT statement only operates on string values and uses some of the built-in functions that DocumentDB provides (CONTAINS and UPPER). The output of this SELECT statement is as follows:

[
  {
    "$1": true
  }
]

Potentially, you could use DocumentDB only for its built-in functions, but it would be an expensive solution.

Aliasing

Collections can be aliased by applying the AS operator:

SELECT p.FirstName, p.LastName FROM PersonInformation AS p

Once we decide to use aliasing, we can no longeruse PersonInformation as...