@@ -217,18 +217,30 @@ public interface PowerSyncDatabase : Queries {
217217 * In this case, PowerSync will not open its own SQLite connections, but rather refer to
218218 * connections in the [pool].
219219 *
220- * The `group ` parameter should likely be teh result of calling [databaseGroup] - this is
221- * responsible for ensuring two instances of the same database file don't sync at the same
222- * time. So, a value that uniquely identifies the database should be passed to
223- * [databaseGroup] .
220+ * The `identifier ` parameter should be a name identifying the path of the database. The
221+ * PowerSync SDK will emit a warning if multiple databases are opened with the same
222+ * identifier, and uses internal locks to ensure these two databases are not synced at the
223+ * same time (which would be inefficient and can cause consistency issues) .
224224 */
225225 @ExperimentalPowerSyncAPI
226226 public fun opened (
227227 pool : SQLiteConnectionPool ,
228228 scope : CoroutineScope ,
229229 schema : Schema ,
230- group : Pair < ActiveDatabaseResource , Any > ,
230+ identifier : String ,
231231 logger : Logger ,
232+ ): PowerSyncDatabase {
233+ val group = ActiveDatabaseGroup .referenceDatabase(logger, identifier)
234+ return openedWithGroup(pool, scope, schema, logger, group)
235+ }
236+
237+ @ExperimentalPowerSyncAPI
238+ internal fun openedWithGroup (
239+ pool : SQLiteConnectionPool ,
240+ scope : CoroutineScope ,
241+ schema : Schema ,
242+ logger : Logger ,
243+ group : Pair <ActiveDatabaseResource , Any >,
232244 ): PowerSyncDatabase =
233245 PowerSyncDatabaseImpl (
234246 schema,
@@ -237,11 +249,5 @@ public interface PowerSyncDatabase : Queries {
237249 logger,
238250 group,
239251 )
240-
241- @ExperimentalPowerSyncAPI
242- public fun databaseGroup (
243- logger : Logger ,
244- identifier : String ,
245- ): Pair <ActiveDatabaseResource , Any > = ActiveDatabaseGroup .referenceDatabase(logger, identifier)
246252 }
247253}
0 commit comments