is there a way to perform an operation within the ...
# room
m
is there a way to perform an operation within the DAO after getting the result from Room, something like
Copy code
@Query("SELECT mutualFriends FROM friends where userId = :userId")
fun getMutualFriends(userId: String): List<Friend> {
    // do some further operation with list
    // like filter or some other
}
k
Yes you can, but would suggest to alleviate these effects to a repository to do actions like filter or map the list.
m
@Kiprop Victor how can I access the list from given Query in the function body?
k
It won't be direct. You will need two functions: 1
Copy code
@Query("SELECT mutualFriends FROM friends where userId = :userId")
fun getMutualFriends(userId: String): List<Friend>
Then 2:
Copy code
fun getFilteredMutualFriends(userId: String): List<Friend> = getMutualFriends().filter{}
These will be in your dao. But, as earlier suggested, the second would be an operation you would do in the repo.
m
currently handling using 2 methods as you mentioned. I thought that there might be a way to achieve using 1 method no issues