question

fool1241-6686 avatar image
0 Votes"
fool1241-6686 asked ·

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


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
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MattiasAsplund-3483 avatar image
1 Vote"
MattiasAsplund-3483 answered ·

I think this does the trick:

 SELECT c.id, { "name": c.nest.name } AS nest FROM c
· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your answer

0 Votes 0 ·