Get newest document per type (grouped by an id field)

Hi Ewan,

Thanks for your elaborate answer to my question, this is indeed similar to how I would usually approach this in Fauna. In this case I was hoping to not have to map/cycle through potentially hundreds of index queries, in order to minimise read operations.

I have for example gotten similar results following your reduce solution from Distinct with custom field - #3 by aprilmintacpineda using just two index queries, but it is definitely not as elegant. And it seems to come at a cost of computing operations, where you gain in read operations.

It would have been great if functions like Distinct or Join would be a little bit more powerful for cases like this, with the risk of oversimplifying things here :-).

Your answer is probably the best answer, so thanks again for your detailed help.

Kind regards,
Fabian

1 Like