Pre-populate data in sqldelight
We are developing apps with KMM architecture, and use the sqldelight as the persistence layer, we want to populate some data on the…
We are developing apps with KMM architecture, and use the sqldelight as the persistence layer, we want to populate some data on the database when the app starts, this is the solution I found for this requirement.
Sqldelight has .sq
file, which contain the sql statements for creating table, index etc, also include some methods which will generate kotlin method automatically.
My solution is add another sq
file, which include the insert sql
, when the table created, the insert sql will also be executed. So the data can be in the database when we use in the app.