Best way to store data to calculate averages?

Hi everyone! I have a database for a project I am working on. Where I am tracking the buys of a specific asset. When that buy gets tracked, I have a collection for that specific asset.

So my collection is called “Assets”, then each asset has its own object/scheme with a “lastBuyTimeStamp” and “totalBuys” field that gets updated when a buy of that asset comes through.

Now i am wanting to pull data to get average number of buys in the past hour and 24 hours, to then also get an average buys per minute.

I feel like with these 2 fields, I may not be able to get this, so looking for some tips or guidance on the best way to store data to get averages I am looking for. I am currently in testing, so hoping to get this worked out before we roll out to production. Thank you!

@Ninja_Dev If you store a time with each buy, you should be able to calculate buy/time rates (“averages”).

Thank you. What I ended up doing was something like that. I just recorded a timestamp on each buy, I then added a function that runs every so often, and removes any objects over the specified time period, and this does the trick!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.