so i am trying to query some data from a cosmos documentdb database as follows
here is my data :
{
"id": "**********",
"triggers": [
{
"type": "enter_an_area",
"trigger_identity": "***********",
},
},
{
"type": "enter_an_area",
"trigger_identity": "********",
},
},
{
"type": "exit_an_area",
"trigger_identity": "*******",
},
this is one document of my collection, where i have a document for every user with a unique ID, now what i want to do is count the number of users that use a specific trigger, a user may have the same trigger multiple times, as you can see in the example "enter_an_area" has more than one entery, but i would still want to count it as one entery.
i use this query to get the count for a specific trigger :
SELECT VALUE COUNT(1) FROM u JOIN t in u.triggers WHERE CONTAINS(t.type, "enter_an_area")
but for the example above this would return: 2 where i want it to return 1
is there a query to do this in documentdb? if there is no such a query, is there a way to return results without duplicates? because as a solution i thought i can return the IDs that use this specific trigger, but then i would get duplicate IDs when a user have more than one entery for a trigger.