delixfe
delixfe

Reputation: 2491

Cosmos DB SQL API: Filter for documents with an empty nested object

What is the easiest way to query for documents having an empty nested object in Azure Cosmos DB.

The document may look like that:

{
    "id": "20352853!2019-06-18T12:45:00.0000000+00:00!1.5.0",
    "TimeStampUtc": "2019-06-18T12:45:00+00:00",
    "MeterId": "20352853",
    "Identifier": "1.5.0",
    "Value": 0.01,
    "State": "00",
    "Unit": "kW",
    "Properties": {},
    "_rid": "1+xXAPJv6UMBAAAAAAAAAA==",
    "_self": "dbs/1+xXAA==/colls/1+xXAPJv6UM=/docs/1+xXAPJv6UMBAAAAAAAAAA==/",
    "_etag": "\"00000000-0000-0000-2b58-5ee6a4c001d5\"",
    "_attachments": "attachments/",
    "_ts": 1561468662
}

I am looking for documents with a nested empty Properties object like in the sample.

Upvotes: 2

Views: 1298

Answers (1)

4c74356b41
4c74356b41

Reputation: 72171

the following seem to work for me:

SELECT * FROM c where c.Properties != {}

that is if you are using SQL API just like your tags suggest

Upvotes: 2

Related Questions