Trying to insert a list of items and Room is throw...
# android
s
Trying to insert a list of items and Room is throwing the following error :
error: Not sure how to handle insert method's return type.
Kotlin version : 1.6.0 Room version : 2.4.2 Here is my DAO :
Copy code
@Dao
interface UserDao {
   .....

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun loadUsers(userCacheEntities: List<UserCacheEntity>): Long

   .....
}
😶 3
t
Your function should probably be declared as
suspend
, otherwise request would have blocked a thread
s
Tried that. Doesn't work. The error is thrown during gradle build so the app doesn't even run.
a
You are inserting a list of values, therefore you cannot return a single long value -- return
Unit
or a list of longs or
LongArray
instead, depending on your needs
✅ 4
s
Bingo! That works. Makes sense. Thanks a lot for this 🙂