modelx

package
v0.39.6 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DatabaseTypeMysql    = "mysql"
	DatabaseTypePostgres = "postgres"
)

Variables

This section is empty.

Functions

func BuildDataSource

func BuildDataSource(c ModelConf) string

func MustSqlConn

func MustSqlConn(c ModelConf) sqlx.SqlConn

func WithCacheConf

func WithCacheConf(cacheConf cache.CacheConf) opts.Opt[ModelOpts]

func WithCacheOpts

func WithCacheOpts(cacheOpts ...cache.Option) opts.Opt[ModelOpts]

func WithCachedConn

func WithCachedConn(cachedConn sqlc.CachedConn) opts.Opt[ModelOpts]

Types

type ModelConf

type ModelConf struct {
	DatabaseType string `json:"databaseType,default=mysql,options=mysql|sqlite|postgres"`
	DatabaseUrl  string `json:"databaseUrl,optional"`

	Mysql    MysqlConf    `json:"mysql,optional"`
	Postgres PostgresConf `json:"postgres,optional"`
}

type ModelOpts

type ModelOpts struct {
	CachedConn *sqlc.CachedConn
	CacheConf  cache.CacheConf
	CacheOpts  []cache.Option
}

func (ModelOpts) DefaultOptions

func (opts ModelOpts) DefaultOptions() ModelOpts

type MysqlConf

type MysqlConf struct {
	Host     string `json:"host,default=localhost"`
	Port     int    `json:"port,default=3306"`
	Username string `json:"username,default=root"`
	Password string `json:"password,default=123456"`
	Database string `json:"database,default=jzero"`
}

type PostgresConf

type PostgresConf struct {
	Host     string `json:"host,default=localhost"`
	Port     int    `json:"port,default=5432"`
	Username string `json:"username,default=root"`
	Password string `json:"password,default=123456"`
	Database string `json:"database,default=jzero"`
	SslMode  string `json:"sslMode,default=disable"`
}

Jump to

Keyboard shortcuts

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