Skip to content

Instantly share code, notes, and snippets.

@TorkelV
Last active February 24, 2021 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TorkelV/dffbb98ceab137a53220662c541c56b4 to your computer and use it in GitHub Desktop.
Save TorkelV/dffbb98ceab137a53220662c541c56b4 to your computer and use it in GitHub Desktop.
snapshot_flow
fun collection(path: String) = Firebase.firestore.collection(path)
override fun getLeaders(): Flow<List<User>> {
return collection("users")
.whereGreaterThan("points", 0)
.orderBy("points", Query.Direction.DESCENDING)
.limit(50)
.asFlow().map { snapshots ->
snapshots.map { it.toUserDto().toUser() }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment