Just learning the ins and outs of CosmosDB. I have the following test documents in CosmosDB:
[
{
"matchingID":123,
"many":{
"meta":"some data",
"items":[
{
"matchingID":921
},
{
"matchingID":123
}
]
}
},
{
"matchingID":1337,
"many":{
"meta":"some more data",
"items":[
{
"matchingID":1337
},
{
"matchingID":1337
}
]
}
},
{
"matchingID":9001,
"many":{
"meta":"all the datas",
"items":[
{
"matchingID":42
},
{
"matchingID":5318008
}
]
}
}
]
Please note these are test documents - the actual documents have many more properties in both the root item as well as the sub items. Each item has a subarray under c.many.items. This sub array has a property that may or may not match the one on it's root. What I'm hoping to achieve is to create a query that will allow me to return items where their subitems ALL match, and another query that will return what ANY of them match.
For example
SELECT * FROM c WHERE ALL(c.many.items.matchingID) = c.matchingID would return the second item, since all the subitem properties match on their parent:
{
"matchingID":1337,
"many":{
"meta":"some more data",
"items":[
{
"matchingID":1337
},
{
"matchingID":1337
}
]
}
}
SELECT * FROM c WHERE ANY(c.many.items.matchingID) = c.matchingID would return the first object, sicne at least one of the sub items matches on the property
{
"matchingID":123,
"many":{
"meta":"some data",
"items":[
{
"matchingID":921
},
{
"matchingID":123
}
]
}
}