Sync Database
- Kotlin
- Java
It serves as the entry point to access
SyncDatabase
.
After initialization, call getInstance() to obtain the instance ofSyncDatabase
associated with the database. Use document() to read and write documents in SyncDatabase.
Summary
Public companion functions | |
---|---|
InitializationState |
SyncDatabase Initializes SyncDatabase synchronously. |
Unit |
SyncDatabase Initializes SyncDatabase asynchronously (callback-based). |
SyncDatabase? |
SyncDatabase Returns an instance of SyncDatabase connected to the specified database. |
Unit |
Cleans up all connections and resources of SyncDatabase. |
Public methods | |
---|---|
SyncDocument |
Returns the document of the specified database. |
Public methods
initialize()
initialize(application: Application, syncConfigsProvider: SyncConfigsProvider)
Initializes SyncDatabase synchronously.
Parameters | |
---|---|
application: Application | Application |
syncConfigsProvider: SyncConfigsProvider | Provider that supplies the necessary information for initializing SyncDatabase. The provider analyzes the config file downloaded from Playground located in the project's assets folder and constructs the initialization information. |
databaseListener: DatabaseListener | A listener that receives information about the initialization result of SyncDatabase and its state asynchronously. |
initialize()
initialize(application: Application, syncConfigsProvider: SyncConfigsProvider, listener: DatabaseListener)
Initializes SyncDatabase asynchronously (callback-based).
Parameters | |
---|---|
application: Application | Application |
syncConfigsProvider: SyncConfigsProvider | A provider that supplies the information required to initialize The provider analyzes the config file downloaded from Playground in the assets folder of the project to construct and provide initialization information. |
databaseListener: DatabaseListener | A listener that receives the result of the asynchronous |
getInstance()
getInstance(databaseName: String)
Returns an instance of SyncDatabase associated with the specified database.
Parameters | |
---|---|
databaseName: String | The name of the database you want to access — this is the name you entered when applying in Playground. |
Returns | |
---|---|
SyncDatabase? | An instance of SyncDatabase linked to the specified database. |
dispose()
fun dispose()
Cleans up all connections and resources of SyncDatabase, making SyncDatabase and SyncDocument unusable.
Public methods
document()
@Throws(SyncException::class)
fun document(documentName: String): SyncDocument
Returns the document of the specified database.
Parameters | |
---|---|
documentName: String | Name of the document to be used |
Returns | |
---|---|
SyncDocument | SyncDocument object representing the document |
The length of the document name must be between 2 and 200 bytes.
It serves as the entry point to access the
SyncDatabase
.
After initialization, you can call getInstance() to retrieve the instance ofSyncDatabase
connected to the corresponding database. To read from or write to a document in SyncDatabase, use the document() method.
Summary
Public static methods | |
---|---|
InitializationState |
SyncDatabase Initializes SyncDatabase synchronously. |
void |
SyncDatabase Initializes SyncDatabase asynchronously (callback method). |
SyncDatabase |
SyncDatabase Returns the instance of SyncDatabase connected to the specified database. |
void |
Cleans up all connections and resources of SyncDatabase. |
Public methods | |
---|---|
SyncDocument |
Returns the document of the specified database. |
Public static methods
initialize()
initialize(@NonNull Application application, @NonNull SyncConfigsProvider syncConfigsProvider)
Initializes SyncDatabase synchronously.
Parameters | |
---|---|
@NonNull Application application | Application |
@NonNull SyncConfigsProvider syncConfigsProvider | Provider that supplies the necessary information for initializing SyncDatabase. The provider analyzes the config file downloaded from Playground in the assets folder of the project to construct and provide initialization information. |
Returns | |
---|---|
InitializationState | A map-like data structure providing the initialization state of each database and the information that affected it. |
initialize()
initialize(@NonNull Application application, @NonNull SyncConfigsProvider syncConfigsProvider, @NonNull DatabaseListener listener)
Initializes SyncDatabase asynchronously (callback-based).
Parameters | |
---|---|
@NonNull Application application | Application |
@NonNull SyncConfigsProvider syncConfigsProvider | Provider that supplies necessary configuration for initializing SyncDatabase. The provider analyzes the configuration file downloaded from Playground, located in the project's assets folder, to construct and provide initialization information. |
@NonNull DatabaseListener databaseListener | A listener that receives the result of asynchronous |
getInstance()
getInstance(@NonNull String databaseName)
Returns an instance of SyncDatabase linked to the specified database.
Parameters | |
---|---|
@Nullable String databaseName | The name of the database to access, as specified during its registration in Playground. |
Returns | |
---|---|
SyncDatabase | An instance of SyncDatabase connected to the specified database. |
dispose()
void dispose()
Cleans up all connections and resources of SyncDatabase, making SyncDatabase and SyncDocument no longer usable.
Public methods
document(@NonNull String documentName)
SyncDocument document(@NonNull String documentName) throws SyncException
Returns the document of the specified database.
Parameters | |
---|---|
@NonNull String documentName | Name of the document to be used |
Returns | |
---|---|
SyncDocument | The SyncDocument object representing the document |
The document name must be between 2 and 200 bytes in length.