Database type represents a jasonisnthappy database connection.
Opening a database
Open
Opens a database at the specified path with default options.Path to the database file
Database instance
Error if the database could not be opened
OpenWithOptions
Opens a database with custom options.Path to the database file
Custom database configuration options
Database instance
Error if the database could not be opened
DefaultDatabaseOptions
Returns the default database options.Default database configuration
Database management
Close
Closes the database and frees associated resources.BeginTransaction
Starts a new transaction.Transaction instance
Error if the transaction could not be started
RunTransaction
Runs a transaction with automatic retries on conflict.Function containing transaction operations
Error if the transaction failed after retries
Configuration
SetTransactionConfig
Sets the transaction retry configuration.Transaction configuration with retry settings
Error if the configuration could not be set
GetTransactionConfig
Gets the current transaction configuration.Current transaction configuration
Error if the configuration could not be retrieved
SetAutoCheckpointThreshold
Sets the auto-checkpoint threshold in WAL frames.Number of WAL frames before automatic checkpoint
Error if the threshold could not be set
Database information
GetPath
Returns the database file path.Database file path
Error if the path could not be retrieved
IsReadOnly
Returns whether the database is read-only.True if the database is read-only
Error if the status could not be checked
ListCollections
Returns a list of all collection names.List of collection names
Error if collections could not be listed
CollectionStats
Returns statistics for a collection.Name of the collection
Collection statistics as a map
Error if stats could not be retrieved
DatabaseInfo
Returns comprehensive database information.Database information including path, size, collections, etc.
Error if info could not be retrieved
MaxBulkOperations
Returns the maximum number of bulk operations allowed.Maximum bulk operations limit
Error if limit could not be retrieved
MaxDocumentSize
Returns the maximum document size in bytes.Maximum document size in bytes
Error if size could not be retrieved
MaxRequestBodySize
Returns the maximum HTTP request body size in bytes.Maximum request body size in bytes
Error if size could not be retrieved
Index management
CreateIndex
Creates a single-field index.Name of the collection
Name for the index
Field to index
Whether the index should enforce uniqueness
Error if index could not be created
CreateCompoundIndex
Creates a compound index on multiple fields.Name of the collection
Name for the index
Fields to include in the compound index
Whether the index should enforce uniqueness
Error if index could not be created
CreateTextIndex
Creates a full-text search index.Name of the collection
Name for the index
Text field to index
Error if index could not be created
DropIndex
Drops an index from a collection.Name of the collection
Name of the index to drop
Error if index could not be dropped
ListIndexes
Returns all indexes for a collection.Name of the collection
List of index metadata
Error if indexes could not be listed
Schema validation
SetSchema
Sets a JSON schema for a collection.Name of the collection
JSON schema for validation
Error if schema could not be set
GetSchema
Gets the JSON schema for a collection.Name of the collection
JSON schema, or nil if no schema is set
Error if schema could not be retrieved
RemoveSchema
Removes the JSON schema from a collection.Name of the collection
Error if schema could not be removed
Maintenance
Checkpoint
Performs a manual WAL checkpoint.Error if checkpoint failed
Backup
Creates a backup of the database.Destination path for the backup file
Error if backup failed
VerifyBackup
Verifies a backup file.Path to the backup file
Backup verification information
Error if verification failed
GarbageCollect
Performs garbage collection and returns statistics.Garbage collection statistics
Error if garbage collection failed
Metrics
Returns database metrics.Database metrics including reads, writes, cache hits, etc.
Error if metrics could not be retrieved
FrameCount
Returns the current WAL frame count.Number of WAL frames
Error if frame count could not be retrieved
Collection access
GetCollection
Gets a collection handle for non-transactional operations.Name of the collection
Collection handle
Error if collection could not be obtained