

SQLDelight in Android: Getting Started
source link: https://www.raywenderlich.com/21631179-sqldelight-in-android-getting-started
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Preparation & Setup
Prepare Your Project
4:16 FreeLearn how SQLDelight is constructed and how it works on a high level on a multitude of platforms. Afterwards, install the required IDE and Gradle plugins to your environment and add the Android-specific driver library as a new dependency to the provided sample project used in this course.
Configure SQLDelight
4:34Learn how to deviate from SQLDelight’s default configuration and tailor it to your specific needs via the domain-specific language exposed by its Gradle plugin.
Familiarize yourself with the .sq file format, used by SQLDelight to describe a table in the generated database. From the scope of the sample app, introduce the intended database relationships and construct the CREATE TABLE statements that make up these models.
Instantiate the Database object generated by SQLDelight and connect it to the existing sample app. Learn about how SQL Drivers are the backbone of the library and how to configure the Android driver specifically. Check out how the underlying AndroidX database can be surfaced for customization and fine-grained configuration.
Learn how SQLDelight stores the columns of generated tables in the underlying SQLite database. Show how different type aliases can affect the generated model classes. For advanced users, show how the library supports custom types through imports and column adapters.
Familiarize yourself with the syntax of functions in SQLDelight and how they add methods to the generated model classes. Using an exemplary workflow of the sample app, create code to insert data into the database and query it with a different function. Furthermore, learn how to get notified whenever the underlying dataset is changed.
Learn about a feature in SQLDelight called grouping statements, wherein multiple SQL statements can be combined under a single name to reduce complexity of the calling Kotlin code.
Learn about the Transaction API in SQLDelight, which allows you to execute multiple statements in Kotlin and commit them all at once. Furthermore, explore how the transaction can be rolled back in case of errors and how to be notified of events related to the ongoing transaction.
Learn how SQL migrations are supported in SQLDelight. This episode introduces the .sqm file format with which the database schema can be migrated to a later version.
Explore how the CREATE VIEW syntax can be used to add SQL Views to your database for common queries. Learn how this can help reduce the amount of types generated by SQLDelight.
Learn about some best practices for unit testing a database schema generated by SQLDelight. Furthermore, familiarize yourself with some ways to automatically validate SQL migrations by means of the Gradle plugin.
Advanced SQLDelight Integrations
Learn about the integration library with RxJava 2 and 3, which allow SQLDelight’s Query type to be observed as RxJava Observables. Apply this extension to the core API of the sample app.
Learn about the integration library with Kotlin Coroutines, which allow SQLDelight’s Query type to be converted into Flows or suspending functions. Apply this extension to the core API of the sample app.
Learn about the integration library with Android Paging, which allows SQLDelight to provide a DataSource implementation that automatically pulls data from a table in a paginated fashion. Refactor the lists of the app to allow for potentially infinite scrolling, powered by Android Paging.
Recommend
-
107
sqldelight - Generates Java models from CREATE TABLE statements.
-
65
A few weeks back I posted a piece about Mobile Oriented Architecture and how I think coding products for screens will evolve. At the end I said I was keeping an eye out for the Kotlin/Native…
-
24
SQLDelight See the project website for documentation and APIs SQLDelight generates typesafe kotlin APIs from your SQL statements. It veri...
-
24
SQLDelightSQLDelight provides libraries and drivers to generate typesafe Kotlin classes from SQL statements that verifies database schemas, st...
-
33
SQLDelight - Generates typesafe Kotlin APIs from SQL - cashapp/sqldelight
-
23
I’ve used Cashapp’s SQLDelight for years in my Android apps. Unlike other ORM libraries, which create an abstraction that allows you to access databases in native code and generates the SQL to access the data for you, SQLDeli...
-
8
-
9
-
9
Kotlin Multiplatform In-Memory SQLDelight Database for Integration and UI Testing on iOS and Android Databases are an integral part of mobile application development, so it's important that these features are properly tested.
-
6
Create a Kotlin/Native Web Server With Ktor and SQLDelight PostgresSQLKotlin server side — but without a JVM
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK