Matti MK
01/12/2022, 9:48 AM1 to N
B
B 1 to N
C
Sometimes I’ll need a List<A>
, sometimes just a List<B>
. Constructing the objects, like A
, based on queries seems a bit confusing to me, so wondering if someone could point me a to a sample that implements something similar? Thanks 👍Matti MK
01/12/2022, 3:34 PMclass A {
val b: List<B>
....
}
class B {
val c: List<C>
...
}
I have tables for all three, so inserting everything into the DB could be done like this:
fun storeResponse(fooDto)
fooDto.listOfA.forEach { A ->
db.queries.insertA(A.toLocalModel())
A.nestedB.forEach { B ->
db.queries.insertB(B.toLocalModel())
/* etc... */
}
Querying the data will then result in something similar.
There must be a better way to do this thoughMatti MK
01/12/2022, 4:05 PM