Database

actual class Database : DelegatedClass<CBLDatabase> , AutoCloseable(source)
expect class Database : AutoCloseable(source)

A Couchbase Lite database.

actual class Database : DelegatedClass<<Error class: unknown class>> , AutoCloseable(source)
actual class Database : AutoCloseable(source)

Constructors

Link copied to clipboard
actual constructor(name: String)
actual constructor(name: String, config: DatabaseConfiguration)
expect constructor(name: String)

Construct a Database with a given name and the default config. If the database does not yet exist it will be created.

expect constructor(name: String, config: DatabaseConfiguration)

Construct a Database with a given name and database config. If the database does not yet exist, it will be created, unless the readOnly option is used.

actual constructor(name: String)
actual constructor(name: String, config: DatabaseConfiguration)
actual constructor(name: String)
actual constructor(name: String, config: DatabaseConfiguration)

Types

Link copied to clipboard
actual object Companion
expect object Companion
actual object Companion
actual object Companion

Properties

Link copied to clipboard

Get all collections in the default scope.

Link copied to clipboard

A READONLY copy of the database configuration.

Link copied to clipboard

Get the default collection.

Link copied to clipboard
actual val defaultScope: Scope
expect val defaultScope: Scope

Get the default scope.

actual val defaultScope: Scope
actual val defaultScope: Scope
Link copied to clipboard
actual val name: String
expect val name: String

The database name

actual val name: String
actual val name: String
Link copied to clipboard
actual val path: String?
expect val path: String?

The database's absolute path or null if the database is closed.

actual val path: String?
actual val path: String?
Link copied to clipboard
actual val scopes: Set<Scope>
expect val scopes: Set<Scope>

Get scope names that have at least one collection. Note: the default scope is exceptional as it will always be listed even though there are no collections under it.

actual val scopes: Set<Scope>
actual val scopes: Set<Scope>

Functions

Link copied to clipboard
actual open override fun close()
expect open override fun close()

Closes a database. Closing a database will stop all replicators, live queries and all listeners attached to it.

actual open override fun close()
actual open override fun close()
Link copied to clipboard

Get all collections in the default scope.

Link copied to clipboard
actual fun createCollection(collectionName: String, scopeName: String?): Collection

Create a named collection in the default scope. If the collection already exists, the existing collection will be returned.

expect fun createCollection(collectionName: String, scopeName: String?): Collection

Create a named collection in the specified scope. If the collection already exists, the existing collection will be returned.

actual fun createCollection(collectionName: String, scopeName: String?): Collection
actual fun createCollection(collectionName: String, scopeName: String?): Collection
Link copied to clipboard
actual fun createQuery(query: String): Query
expect fun createQuery(query: String): Query

Create a SQL++ query.

actual fun createQuery(query: String): Query
actual fun createQuery(query: String): Query
Link copied to clipboard

Get the default collection.

Link copied to clipboard

Get the default scope.

Link copied to clipboard
actual fun delete()
expect fun delete()

Deletes a database. Deleting a database will stop all replicators, live queries and all listeners attached to it. Although attempting to close a closed database is not an error, attempting to delete a closed database is.

actual fun delete()
actual fun delete()
Link copied to clipboard
actual fun deleteCollection(name: String)
actual fun deleteCollection(collectionName: String, scopeName: String?)
expect fun deleteCollection(name: String)

Delete a collection by name in the default scope. If the collection doesn't exist, the operation will do nothing. Note: the default collection cannot be deleted.

expect fun deleteCollection(collectionName: String, scopeName: String?)

Delete a collection by name in the specified scope. If the collection doesn't exist, the operation will do nothing. Note: the default collection cannot be deleted.

actual fun deleteCollection(name: String)
actual fun deleteCollection(collectionName: String, scopeName: String?)
actual fun deleteCollection(name: String)
actual fun deleteCollection(collectionName: String, scopeName: String?)
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
actual fun getCollection(name: String): Collection?
actual fun getCollection(collectionName: String, scopeName: String?): Collection?
expect fun getCollection(name: String): Collection?

Get a collection in the default scope by name. If the collection doesn't exist, the function will return null.

expect fun getCollection(collectionName: String, scopeName: String?): Collection?

Get a collection in the specified scope by name. If the collection doesn't exist, the function will return null.

actual fun getCollection(name: String): Collection?
actual fun getCollection(collectionName: String, scopeName: String?): Collection?
actual fun getCollection(name: String): Collection?
actual fun getCollection(collectionName: String, scopeName: String?): Collection?
Link copied to clipboard
actual fun getCollections(scopeName: String?): Set<Collection>
expect fun getCollections(scopeName: String?): Set<Collection>

Get all collections in the named scope.

actual fun getCollections(scopeName: String?): Set<Collection>
actual fun getCollections(scopeName: String?): Set<Collection>
Link copied to clipboard
actual fun getScope(name: String): Scope?
expect fun getScope(name: String): Scope?

Get a scope object by name. As the scope cannot exist by itself without having a collection, the null value will be returned if there are no collections under the given scope’s name. Note: The default scope is exceptional, and it will always be returned.

actual fun getScope(name: String): Scope?
actual fun getScope(name: String): Scope?
Link copied to clipboard
open override fun hashCode(): Int
open override fun hashCode(): Int
open override fun hashCode(): Int
Link copied to clipboard
actual fun <R> inBatch(work: Database.() -> R): R
expect fun <R> inBatch(work: Database.() -> R): R

Runs a group of database operations in a batch. Use this when performing bulk write operations like multiple inserts/updates; it saves the overhead of multiple database commits, greatly improving performance.

actual fun <R> inBatch(work: Database.() -> R): R
actual fun <R> inBatch(work: Database.() -> R): R
Link copied to clipboard

Perform database maintenance.

actual fun performMaintenance(type: <Error class: unknown class>): Boolean
Link copied to clipboard
fun scopes(): Set<Scope>

Get scope names that have at least one collection. Note: the default scope is exceptional as it will always be listed even though there are no collections under it.

Link copied to clipboard
open override fun toString(): String
open override fun toString(): String
open override fun toString(): String