For Firebase RealtimeDatabase,
Can I enter a function (such as summing the values ​​for a particular key) in the value?

No information found on the official website or online ...
I would be pleased if anyone could give me a hint.

■ Background
I would like to create an iOS app that can perform voting simulations of horse racing that can be participated by an unspecified number of people online.
It feels like there are no dividends depending on the result.

On creation, on Firebase RealtimeDatabase
I would like to register data such as user/race/wager amount, etc.
An item that displays the total amount of money bet per race is required.
I wonder if a function is needed instead of a value.

However, it is difficult to find a way to fill in.

Thanks for your patience.