Skip to content

Commit 09cd161

Browse files
authored
Correct powersyncdatabase code example for kotlin (#152)
* Correct powersyncdatabase code example for kotlin * Update client-sdk-references/kotlin-multiplatform.mdx * Update client-sdk-references/kotlin-multiplatform.mdx * Update migration-guides/mongodb-atlas.mdx
1 parent 46462a7 commit 09cd161

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

client-sdk-references/kotlin-multiplatform.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,13 @@ b. Build a `PowerSyncDatabase` instance using the `PowerSyncBuilder` and the `Da
125125
```kotlin
126126
// commonMain
127127

128-
// Uses the backend connector that will be created in the next step
129-
database.connect(MyConnector())
128+
val database = PowerSyncDatabase({
129+
factory: driverFactory, // The factory you defined above
130+
schema: AppSchema, // The schema you defined in the previous step
131+
dbFilename: "powersync.db"
132+
// logger: YourLogger // Optionally include your own Logger that must conform to Kermit Logger
133+
// dbDirectory: "path/to/directory" // Optional. Directory path where the database file is located. This parameter is ignored for iOS.
134+
});
130135
```
131136

132137
c. Connect the `PowerSyncDatabase` to the backend connector:

migration-guides/mongodb-atlas.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,14 @@ Now that we have our Sync Rules and client-side schema defined, we can instantia
344344
// 2: Build a PowerSyncDatabase instance using the PowerSyncBuilder and the DatabaseDriverFactory. The schema you created in a previous step is provided as a parameter:
345345
346346
// commonMain
347-
// Uses the backend connector that will be created in the next step
348-
database.connect(MyConnector())
347+
348+
val database = PowerSyncDatabase({
349+
factory: driverFactory, // The factory you defined above
350+
schema: AppSchema, // The schema you defined in the previous step
351+
dbFilename: "powersync.db"
352+
// logger: Logger? = YourLogger // Optionally include your own Logger that must conform to Kermit Logger
353+
// dbDirectory: "path/to/directory" // Optional. Directory path where the database file is located. This parameter is ignored for iOS.
354+
});
349355
350356
351357
// 3: Connect the PowerSyncDatabase to the backend connector:

0 commit comments

Comments
 (0)