database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbTypeMysql = "mysql"
)
View Source
const (
	DbTypeSqlite = "sqlite"
)

Variables

View Source
var FactoryDialector = map[string]CreateDialectorFn{}

Functions

func ApplySort

func ApplySort(query *gorm.DB, allowedColumns map[string]string, sorts []SortInput, tablePrefix string) *gorm.DB

ApplySort applique les tris à une requête GORM allowedColumns: map[jsonName]dbColumnName tablePrefix: préfixe de table pour les jointures (optionnel, "" si pas de jointure)

func CreateDB

func CreateDB(ctx *context.Context) (*gorm.DB, error)

func CreateDialectorMysql

func CreateDialectorMysql(ctx *context.Context, cfg config.DbConfig) (gorm.Dialector, error)

func CreateDialectorSqlite

func CreateDialectorSqlite(ctx *context.Context, cfg config.DbConfig) (gorm.Dialector, error)

Types

type CreateDialectorFn

type CreateDialectorFn func(ctx *context.Context, cfg config.DbConfig) (gorm.Dialector, error)

type MysqlConfig

type MysqlConfig struct {
	DSN string `mapstructure:"dsn" validate:"required"`
}

type SortDirection

type SortDirection string
const (
	SortASC  SortDirection = "ASC"
	SortDESC SortDirection = "DESC"
)

type SortInput

type SortInput struct {
	Column    string
	Direction SortDirection
}

type SqliteConfig

type SqliteConfig struct {
	DSN string `mapstructure:"dsn" validate:"required"`
}

Jump to

Keyboard shortcuts

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