Get objects fields values from array in CosmosDB

Viewed 2239

I have a query for CosmosDB:

SELECT food.tags FROM food

which returns this:

{
  "tags": [
    {
      "name": "babyfood"
    },
    {
      "name": "dessert"
    },
    {
      "name": "fruit pudding"
    },
    {
      "name": "orange"
    },
    {
      "name": "strained"
    }
  ]
}

I would like to create a query to obtain results like:

["babyFood", "dessert", "fruit pudding", "orange", "strained"] 

so my goal is to get an array which will contain values of 'name' field from all objects in 'tags' array.

How could it be done in CosmosDB SQL?

Please help.

1 Answers
Related