matt tighe
09/18/2019, 9:17 PM@Ignore
annotation used for room in Kotlin? what I want is something like this:
@Entity
data class Foo(
@PrimaryKey(autoGenerate = true) val id: Long,
val name: String = "",
@Ignore val bars: List<Bar> = listOf()
)
but I get Entities and POJOs must have a usable public constructor.
Bar
is another entity and the lists will be ideally constructed at the repository level like so
suspend fun observeAll(): Flow<List<Foo>> {
return fooDao.observeAll().map { list -> list.map { foo ->
val bars = barDao.getBarsByFooId(foo.id).map { it.bar }
foo.copy(bars = bars)
} }
}