CosmosDB Mongo - What's the better way to check if an array is empty ?

Kais Khan Hadi 0 Reputation points
2024-01-24T10:10:32.0566667+00:00

Hey I want to check if some of my arrays on a document are empty. Right now I'm doing a simple

{"myArray": []}

(eq operation), because I know that using the $size operator would prevent MongoDB to use any indexes (it would be like this :

{"myArray": {$size: 0}}

But since MongoDB and CosmosDB have some discrepancies (especially the indexes doesn't work the same), I wondered if this was really the case when using Cosmos ? I didn't find anything related in the documentation. Thanks for your help.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,902 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.