'Cosmos DB : Find the index of an item in an array
I want to find the index number of all items in a nested array in Cosmos DB :
Data :
{
"id":"MyId",
"items" : [
{"id": "Item1"},
{"id" : "Item2"}
]
}
Query :
SELECT f.id, index : ** How to get the index of items ? **
FROM root JOIN f IN root["items"]
WHERE (IS_DEFINED(root["items"]) AND (root["id"] = "MyId"))
I would like a result like this :
[
{"id": "item1", "index": 0},
{"id": "item2", "index" : 1}
]
Thx
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
