Using db.collection.distinct() within the aggregation framework

Hi, @santimir, and thanks for your answer.

I’m using a BI software that only accepts AF queries strictly formatted as JSON. So I cannot define a constant and then do some other thing, I’m not working in the Mongo shell.

That piece of code works really well within my current query: when testing it against the server using another software, called NoSQL Booster, I get results in less than 5 seconds. So I need to format it properly -which it seems it’s not possible- or to change its syntax in a way it might be properly “jsonized”.

I thought this could be an alternative but equivalent syntax:

"idDevice": {"$in": ["distinct": "devices", "key": "_id", "query": {"group.$id": 11}]}

But I get no results when I try it in NoSQL Booster.