Skip to content

Add collection.select(fields) to Firestore #644

Closed
@mixtly87

Description

@mixtly87
Library Class Member Platforms
Firestore collection select all

Would be useful to support retrieving only specific fields from Firestore documents.

Something like:

fun getCities() = flow {
    firestore.collection("cities")
        .select("name", "population")
        .snapshots.collect { snapshot ->
        val cities = snapshot.documents.map { doc ->
            doc.data<City>()
        }.sortedBy { it.name }
        emit(cities)
    }
}

Idea is to only fetch needed fields and prevent network-transport of potentially heavy documents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API coverageRequest for missing APIs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions