-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef933db
commit 3310663
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
composeApp/src/commonMain/kotlin/com/clipevery/data/DriverFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.clipevery.data | ||
|
||
import app.cash.sqldelight.db.SqlDriver | ||
import com.clipevery.Database | ||
|
||
expect class DriverFactory { | ||
fun createDriver(): SqlDriver | ||
} | ||
|
||
fun createDatabase(driverFactory: DriverFactory): Database { | ||
val driver = driverFactory.createDriver() | ||
val database = Database(driver) | ||
|
||
// Do more work with the database (see below). | ||
return database; | ||
} |
9 changes: 9 additions & 0 deletions
9
composeApp/src/commonMain/sqldelight/com/clipevery/data/Player.sq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE hockeyPlayer ( | ||
player_number INTEGER PRIMARY KEY NOT NULL, | ||
full_name TEXT NOT NULL | ||
); | ||
|
||
CREATE INDEX hockeyPlayer_full_name ON hockeyPlayer(full_name); | ||
|
||
INSERT INTO hockeyPlayer (player_number, full_name) | ||
VALUES (15, 'Ryan Getzlaf'); |
13 changes: 13 additions & 0 deletions
13
composeApp/src/desktopMain/kotlin/com/clipevery/data/DriverFactory.desktop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.clipevery.data | ||
|
||
import app.cash.sqldelight.db.SqlDriver | ||
import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver | ||
import com.clipevery.Database | ||
|
||
actual class DriverFactory { | ||
actual fun createDriver(): SqlDriver { | ||
val driver: SqlDriver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY) | ||
Database.Schema.create(driver) | ||
return driver | ||
} | ||
} |