Is there a way to get the full path of the key when querying Azure Cosmos DB?

fool1241 81 Reputation points
2021-03-07T16:21:22.327+00:00

If you execute a SQL query to Cosmos DB where the following JSON is registered, the nest key will be omitted.

Is there a way to get the full path of the key when querying Azure Cosmos DB?

  • JSON DATA json
    {
    "id": "001",
    "nest":
    {
    "name": "Tom",
    "age": 45
    }
    }
    • Query Result
    SELECT c.id, c.nest.name FROM c {
    "id": "001",
    "name": "Tom"
    }
  • Query result I'm expecting SELECT c.id, c.nest.name FROM c {
    "id": "001",
    "nest":
    {
    "name": "Tom"
    }

    }

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,449 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mattias Asplund 236 Reputation points
    2021-03-07T16:52:12.95+00:00

    I think this does the trick:

    SELECT c.id, { "name": c.nest.name } AS nest FROM c
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful