From the Transactions doc, second paragraph:
The intention here is for the client to increment the total number of chat messages sent (ignore for a moment that there are better ways of implementing this).
What are some standard "better ways" of implementing this?
Specifically, I'm looking at trying to do things like retrieve the most recent 50 records. This requires that I start from the end of the list, so I need a way to determine what the last record is.
The options as I see them:
- use a transaction to update a counter each time a record is added, use the counter value with setPriority() for ordering
- forEach() the parent and read all records, do my own sorting/filtering at client
- write server code to analyze Firebase tables and create indexed lists like "mostRecent Messages" and "totalNumberOfMessages"
Am I missing obvious choices?