ch

package
v1.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClickHouseDB

type ClickHouseDB struct {
	// contains filtered or unexported fields
}

func NewClickHouseDB

func NewClickHouseDB(config conf.DBClickHouseConfig) *ClickHouseDB

NewClickHouseDB creates a new instance of ClickHouseDB, configuring it with options for automatic migration, the DSN key, and the models to be migrated.

Parameters:

  • config: conf.DBClickHouseConfig struct containing AutoMigrate flag, the DSN key, and models slice for database migration.

Returns:

  • A new ClickHouseDB instance.

func (*ClickHouseDB) GetDB

func (d *ClickHouseDB) GetDB() *gorm.DB

GetDB returns the active ClickHouse database connection.

Returns:

  • The *gorm.DB instance representing the database connection.

func (*ClickHouseDB) InitDB

func (d *ClickHouseDB) InitDB()

InitDB initializes the ClickHouse database connection using GORM and the provided DSN. If auto-migration is enabled, it will migrate the provided models automatically.

If auto-migration is disabled, the method will log that manual migration is expected.

Logs an error and terminates the program if the database connection or migration fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL