O'Reilly logo

Guide to NoSQL with Azure Cosmos DB by Daron Yondem, Gaston C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with schema-agnostic queries

The VideoGames1 collection has two documents. The document with id equal to 2 has a platforms key whose value is an array of string with the platforms in which the video game can be executed. The document with id equal to 1 doesn't include the platforms key.

Now we will write a query that will indicate the properties we want to retrieve from all the documents in the collection. Specifically, we will specify we want to retrieve the name and platforms properties. In addition, we will request the results to be sorted by name in ascending order. The code file for the sample is included in the learning_cosmos_db_03_01 folder in the sql_queries/videogame_1_03.sql file:

SELECT v.name, v.platforms FROM Videogames ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required