Filtering Firestore collection on DocumentReference snapshot “metadata”

According to Firestore docs, collections can be filtered by the API client using methods like .where(), .limit() and .limit_to_last() : docs

However, the FilterField argument in .where() supports queryable fields in the collection, which means you cannot use it to filter records on document attributes like update_time and id.

Unfortunately, my collection does not include last updated or document id fields but they are accessible in DocumentReference snapshot data (collection().get()[i].id and collection().get()[i].update_time).

What is the easiest way to filter the API for recently updated documents if your collection does not include a queryable field like update_time? Sorting and filtering the entire collection results in a timeout when using stream() to return all documents in the collection. Limit to last and limit do not seem to work since the collection also needs to be sorted on a queryable field.

I’ve tried various implementations of where, limit, and limit to last

Leave a Comment