db

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetManager

func GetManager() *manager

GetManager - This function returns singleton instance of Db Manager

func NewCreateMongoWrapperErr

func NewCreateMongoWrapperErr(err error) error

NewCreateMongoWrapperErr - return a new instance of CreateMongoWrapperErr

func NewCreateSqlWrapperErr

func NewCreateSqlWrapperErr(err error) error

NewCreateSqlWrapperErr - return a new instance of CreateSqlWrapperErr

func NewDeleteModelErr

func NewDeleteModelErr(table string, data any, err error) error

NewDeleteModelErr - return a new instance of DeleteModelErr

func NewInsertModelErr

func NewInsertModelErr(table string, data any, err error) error

NewInsertModelErr - return a new instance of InsertModelErr

func NewMigrateErr

func NewMigrateErr(err error) error

NewMigrateErr - return a new instance of MigrateErr

func NewMongoDeleteErr

func NewMongoDeleteErr(collection string, filter any, err error) error

NewMongoDeleteErr - return a new instance of MongoDeleteErr

func NewMongoFindQueryErr

func NewMongoFindQueryErr(collection string, filter any, err error) error

NewMongoFindQueryErr - return a new instance of MongoFindQueryErr

func NewNotExistServiceNameErr

func NewNotExistServiceNameErr(serviceName string) error

NewNotExistServiceNameErr - return a new instance of NotExistServiceNameErr

func NewNotImplementedErr

func NewNotImplementedErr() error

NewNotImplementedErr - return a new instance of NotImplementedErr

func NewNotSupportedDbTypeErr

func NewNotSupportedDbTypeErr(dbType string) error

NewNotSupportedDbTypeErr - return a new instance of NotSupportedDbTypeErr

func NewSelectQueryErr

func NewSelectQueryErr(q string, err error) error

NewSelectQueryErr - return a new instance of SelectQueryErr

func NewUpdateModelErr

func NewUpdateModelErr(table string, data any, err error) error

NewUpdateModelErr - return a new instance of UpdateModelErr

Types

type Config

type Config struct {
	SkipDefaultTransaction                   bool `json:"skip_default_transaction"`
	DryRun                                   bool `json:"dry_run"`
	PrepareStmt                              bool `json:"prepare_stmt"`
	DisableAutomaticPing                     bool `json:"disable_automatic_ping"`
	DisableForeignKeyConstraintWhenMigrating bool `json:"disable_foreign_key_constraint_when_migrating"`
	IgnoreRelationshipsWhenMigrating         bool `json:"ignore_relationships_when_migrating"`
	DisableNestedTransaction                 bool `json:"disable_nested_transaction"`
}

type CreateMongoWrapperErr

type CreateMongoWrapperErr struct {
	Err error
}

CreateMongoWrapperErr Error

func (*CreateMongoWrapperErr) Error

func (err *CreateMongoWrapperErr) Error() string

Error method - satisfying error interface

type CreateSqlWrapperErr

type CreateSqlWrapperErr struct {
	Err error
}

CreateSqlWrapperErr Error

func (*CreateSqlWrapperErr) Error

func (err *CreateSqlWrapperErr) Error() string

Error method - satisfying error interface

type DeleteModelErr

type DeleteModelErr struct {
	Err error
	// contains filtered or unexported fields
}

DeleteModelErr Error

func (*DeleteModelErr) Error

func (err *DeleteModelErr) Error() string

Error method - satisfying error interface

type InsertModelErr

type InsertModelErr struct {
	Err error
	// contains filtered or unexported fields
}

InsertModelErr Error

func (*InsertModelErr) Error

func (err *InsertModelErr) Error() string

Error method - satisfying error interface

type LoggerConfig

type LoggerConfig struct {
	SlowThreshold             int64  `json:"slow_threshold"`
	IgnoreRecordNotFoundError bool   `json:"ignore_record_not_found_error"`
	ParameterizedQueries      bool   `json:"parameterized_queries"`
	LogLevel                  string `json:"log_level"`
}

type MigrateErr

type MigrateErr struct {
	Err error
}

MigrateErr Error

func (*MigrateErr) Error

func (err *MigrateErr) Error() string

Error method - satisfying error interface

type Mongo

type Mongo struct {
	DatabaseName string             `json:"db"`
	Username     string             `json:"username"`
	Password     string             `json:"password"`
	Host         string             `json:"host"`
	Port         string             `json:"port"`
	Options      map[string]string  `json:"options"`
	LoggerConfig *MongoLoggerConfig `json:"logger"`
}

type MongoDeleteErr

type MongoDeleteErr struct {
	Err error
	// contains filtered or unexported fields
}

MongoDeleteErr Error

func (*MongoDeleteErr) Error

func (err *MongoDeleteErr) Error() string

Error method - satisfying error interface

type MongoFindQueryErr

type MongoFindQueryErr struct {
	Err error
	// contains filtered or unexported fields
}

MongoFindQueryErr Error

func (*MongoFindQueryErr) Error

func (err *MongoFindQueryErr) Error() string

Error method - satisfying error interface

type MongoLoggerConfig

type MongoLoggerConfig struct {
	MaxDocumentLength   int    `json:"max_document_length"`
	ComponentCommand    string `json:"component_command"`
	ComponentConnection string `json:"component_connection"`
}

type MongoWrapper

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

SqlWrapper struct

func NewMongoWrapper

func NewMongoWrapper(name string) (*MongoWrapper, error)

NewMongoWrapper - create a new instance of MongoWrapper and returns it

func (*MongoWrapper) GetDb

func (m *MongoWrapper) GetDb() (*mongo.Database, error)

GetDb - return associated internal Db

type Mysql

type Mysql struct {
	DatabaseName   string               `json:"db"`
	Username       string               `json:"username"`
	Password       string               `json:"password"`
	Host           string               `json:"host"`
	Port           string               `json:"port"`
	Protocol       string               `json:"protocol"`
	Options        map[string]string    `json:"options"`
	Config         *Config              `json:"config"`
	LoggerConfig   *LoggerConfig        `json:"logger"`
	SpecificConfig *MysqlSpecificConfig `json:"specific_config"`
}

type MysqlSpecificConfig

type MysqlSpecificConfig struct {
	DefaultStringSize         uint `json:"default_string_size"`
	DisableDatetimePrecision  bool `json:"disable_datetime_precision"`
	DefaultDatetimePrecision  int  `json:"default_datetime_precision"`
	SupportRenameIndex        bool `json:"support_rename_index"`
	SupportRenameColumn       bool `json:"support_rename_column"`
	SkipInitializeWithVersion bool `json:"skip_initialize_with_version"`
	DisableWithReturning      bool `json:"disable_with_returning"`
	SupportForShareClause     bool `json:"support_for_share_clause"`
	SupportNullAsDefaultValue bool `json:"support_null_as_default_value"`
	SupportRenameColumnUnique bool `json:"support_rename_column_unique"`
}

type NotExistServiceNameErr

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

NotExistServiceNameErr Error

func (*NotExistServiceNameErr) Error

func (err *NotExistServiceNameErr) Error() string

Error method - satisfying error interface

type NotImplementedErr

type NotImplementedErr struct {
}

NotImplementedErr Error

func (*NotImplementedErr) Error

func (err *NotImplementedErr) Error() string

Error method - satisfying error interface

type NotSupportedDbTypeErr

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

NotSupportedDbTypeErr Error

func (*NotSupportedDbTypeErr) Error

func (err *NotSupportedDbTypeErr) Error() string

Error method - satisfying error interface

type Postgresql

type Postgresql struct {
	DatabaseName   string                    `json:"db"`
	Username       string                    `json:"username"`
	Password       string                    `json:"password"`
	Host           string                    `json:"host"`
	Port           string                    `json:"port"`
	Options        map[string]string         `json:"options"`
	Config         *Config                   `json:"config"`
	LoggerConfig   *LoggerConfig             `json:"logger"`
	SpecificConfig *PostgresqlSpecificConfig `json:"specific_config"`
}

type PostgresqlSpecificConfig

type PostgresqlSpecificConfig struct {
	PreferSimpleProtocol bool  `json:"prefer_simple_protocol"`
	WithoutReturning     bool  `json:"without_returning"`
	MaxIdleConnCount     int64 `json:"max_idle_conn_count"`
	MaxOpenConnCount     int64 `json:"max_open_conn_count"`
	ConnMaxLifetime      int64 `json:"conn_max_lifetime"`
}

type SelectQueryErr

type SelectQueryErr struct {
	Err error
	// contains filtered or unexported fields
}

SelectQueryErr Error

func (*SelectQueryErr) Error

func (err *SelectQueryErr) Error() string

Error method - satisfying error interface

type SqlConfigurable

type SqlConfigurable interface {
	Sqlite | Mysql | Postgresql
}

type SqlWrapper

type SqlWrapper[T SqlConfigurable] struct {
	// contains filtered or unexported fields
}

SqlWrapper struct

func NewSqlWrapper

func NewSqlWrapper[T SqlConfigurable](name string, dbType string) (*SqlWrapper[T], error)

NewSqlWrapper - create a new instance of SqlWrapper and returns it

func (*SqlWrapper[T]) AttachMigrationFunc

func (s *SqlWrapper[T]) AttachMigrationFunc(f func(migrator gorm.Migrator) error) error

AttachMigrationFunc - attach migration function to be called by end user

func (*SqlWrapper[T]) GetDb

func (s *SqlWrapper[T]) GetDb() (*gorm.DB, error)

GetDb - return associated internal Db

func (*SqlWrapper[T]) Migrate

func (s *SqlWrapper[T]) Migrate(models ...interface{}) error

Migrate - migrate models to the database

func (*SqlWrapper[T]) RegisterLogger

func (s *SqlWrapper[T]) RegisterLogger(l types.Logger)

RegisterLogger - register logger instance

type Sqlite

type Sqlite struct {
	FileName     string            `json:"db"`
	Options      map[string]string `json:"options"`
	Config       *Config           `json:"config"`
	LoggerConfig *LoggerConfig     `json:"logger"`
}

type UpdateModelErr

type UpdateModelErr struct {
	Err error
	// contains filtered or unexported fields
}

UpdateModelErr Error

func (*UpdateModelErr) Error

func (err *UpdateModelErr) Error() string

Error method - satisfying error interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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