Problem with distinct query

Hi, I’m trying to use the distinct query without success :sweat_smile: since in a table there would be more items still not updated by a cron with same values and I don’t want to have duplicates, I’m doing something like this:

query.equalTo("available", false);
query.equalTo("sold", false);

//... other equalTo or filters

query.distinct("tokenId", { useMasterKey: true });
const items = await query.find({ useMasterKey: true });

The cron when is executed is setting to true one of available and sold, so just one item per time is available, but this is still returning two (and potentially more) for the same tokenId before the cron is executed.

Thank you

I think that you have to filter them after that to identify what is unique.

I don’t know how to get them distinct with a query.