Skip to content

Commit

Permalink
Add map method to ListWithTotalCount
Browse files Browse the repository at this point in the history
  • Loading branch information
hermannm committed Apr 11, 2024
1 parent 5837ba4 commit 7990954
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ EntityT : EntityRoot<EntityIdT> {
data class ListWithTotalCount<T>(
val list: List<T>,
val totalCount: Long,
)
) {
/** Maps the elements of the list, while keeping the same [totalCount]. */
fun <R> map(transform: (T) -> R): ListWithTotalCount<R> {
return ListWithTotalCount(
list = this.list.map(transform),
totalCount = this.totalCount,
)
}
}

/**
* An alternative to [AbstractSearchRepository] for when you pass a `limit` but still want the total
Expand Down

0 comments on commit 7990954

Please sign in to comment.