Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Document Query Sub Dictionaries

I have stored the following JSON document in the Azure Document DB:

"JobId": "04e63d1d-2af1-42af-a349-810f55817602",
"JobType": 3,
"
"Properties": [
  {
    "Key": "Value1",
    "Value": "testing1"
  },
  {
    "Key": "Value",
    "Value": "testing2"
  }
]

When i try to query the document back i can easily perform the

Select f.id,f.Properties, C.Key from f Join C IN f.Properties where C.Key = 'Value1'

However when i try to query: Select f.id,f.Properties, C.Key from f Join C IN f.Properties where C.Value = 'testing1'

I get an error that the query cannot be computed. I assume this is due to 'VALUE' being a reserved keyword within the query language.

I cannot specify a specific order in the property array because different subclasses can add different property in different orders as they need them.

Anybody any suggestion how i can still complete this query ?

like image 551
CrazyBernie Avatar asked Jun 02 '26 07:06

CrazyBernie


1 Answers

To escape keywords in DocumentDB, you can use the [] syntax. For example, the above query would be:

Select f.id,f.Properties, C.Key from f Join C IN f.Properties where C["Value"] = 'testing1'
like image 111
Aravind Krishna R. Avatar answered Jun 05 '26 02:06

Aravind Krishna R.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!