Persisting data in a local database
We'll be using SQLDelight (https://github.com/cashapp/sqldelight) for Dogify, though there are other possibilities including NoSQL solutions as well, such as Realm (https://github.com/realm/realm-kotlin) and Kodein-DB (https://github.com/Kodein-Framework/Kodein-DB).
In this section, we're going to do the following:
- Explore how to set up SQLDelight in a multiplatform module.
- Implement the
BreedsLocalSource
. - Connect the remaining API functionality to our database.
Let's dive in.
Exploring how to set up SQLDelight in a multiplatform module
As always, the first thing is to add the needed dependencies, so we need to do the following chores:
- Add the plugin to the
classpath
: addclasspath("com.squareup.sqldelight:gradle-plugin:$sqlDelightVersion")
to the top-levelbuild.gradle.kts
. - Apply the plugin to our shared module, by adding
id("com.squareup.sqldelight")
to theplugins
block...