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

Setting consistency levels


DocumentDB offers different levels of consistency. Again, this is a matter of balancing between performance, consistency, and latency. DocumentDB offers four levels of consistency, each with its own characteristics.

Consistency levels can only be set on user defined resources such as documents and triggers. By default, all system resources such as databases and collections are strongly consistency enabled. The following types of consistency levels are available:

  • Strong

  • Bounded staleness

  • Session

  • Eventual

Setting the consistency level can be accomplished using the designated SDKs or the Azure portal, as shown in the following screenshot:

Using strong consistency

Strong consistency means that a write to a collection, database, or some other user defined resource is visible only after it is committed by the majority of the replicas. This means that a client cannot face an uncommitted write and DocumentDB always guarantees to return the latest write that was successful.

This...