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

Reading resources


Let's see how to perform some basic reading operations on your collection. We extend the PersonInformation class with more fields to be able to demonstrate some more detailed querying capabilities. The PersonInformation class now also contains a list of roles a person can have. This enables us to query on the Roles property as well.

The class is defined as follows:

public class PersonInformation : Resource
{
  public string LastName { get; set; }
  public string FirstName { get; set; }
  public DateTime DateOfBirth { get; set; }

  public List<Role> Roles { get; set; }
}

public class Role
{
  public string RoleName {get;set;}
}

Reading documents

In this section, we will use the Roles property of the PersonInformation class and start querying it using the three methodologies demonstrated in the previous sections. After creating a few documents containing different persons with different roles, we can query for all persons with the role Administrator assigned to them...