Getting Trending Items from FireStore
05:46 09 Nov 2025

I am trying to use firestore and get a top list of items saved into the database. I want for example the top newest, top most worn, and top trending.

An item in the datastore looks something like this. The issue is that for trending items I need a formula to calculate the top items (see below). Any idea how to do this?

gravity = 0.2

ranking = amountWorn / (daysSincePost * gravity)
{
    ItemId: 1234567890,
    AddDate: 01/01/2025,
    AmountWorn: 0
} 
database google-cloud-firestore