I’m working with SQLDelight and I have the followi...
# squarelibraries
m
I’m working with SQLDelight and I have the following relation A
1 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 👍
To give a little bit more information, I get the following from a remote source:
Copy code
class 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:
Copy code
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 though
I guess one way to optimise this would be to bulk insert the list but based on this it might not be straightforward https://github.com/cashapp/sqldelight/issues/548#issuecomment-772101180