Deleting the oldest of a sub-collection documents

I’m working on a quiz game, and the results are stored in the "results" sub-collections of the "users collection" on firestore and retrieved to a list view. As the users engage with the game, they continuously build result documents at the backend

How do I delete the oldest documents from the "results" sub-collection and retain only 5 of the latest documents

1 reply