ormx

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

* @Author: hugo * @Date: 2024-04-19 16:18 * @LastEditors: hugo2lee * @LastEditTime: 2025-03-17 14:34 * @FilePath: \gotox\ormx\ormx.go * @Description: * * Copyright (c) 2024 by hugo, All Rights Reserved.

Index

Constants

View Source
const (
	DefaultProjectName         = DefaultMysqlProjectName
	MYSQL                      = "mysql"
	DefaultMysqlProjectName    = ""
	POSTGRES                   = "postgres"
	DefaultPostgresProjectName = "public"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID      uint  `gorm:"primaryKey;autoIncrement"`
	Created int64 `gorm:"autoCreateTime:milli"`
	Updated int64 `gorm:"autoUpdateTime:milli"`
	Deleted gorm.DeletedAt
	UUID    string `gorm:"size:36;uniqueIndex"`
}

type Option

type Option func(*Ormx) error

func WithMysql

func WithMysql(tableNamePrefixList ...string) Option

WithMysql is a shortcut for WithMysqlTableNamePrefix In very first version, we only support one mysql db with mutilple project tables to be separated start at 2025.03.31 not recommend to use

func WithMysqlMultipleDb added in v0.1.3

func WithMysqlMultipleDb(dbNameList ...string) Option

dbNameList is mysql[yourDbName].dsn in *.toml

func WithMysqlMultipleTableNamePrefix added in v0.1.3

func WithMysqlMultipleTableNamePrefix(tableNamePrefixList ...string) Option

default dsn is mysql.dsn in *.toml

func WithPostgres

func WithPostgres(schemaNameList ...string) Option

WithPostgres is a shortcut for WithPostgresSchema In very first version, we only support one postgres db with mutilple project schema to be separated start at 2025.03.31 not recommend to use

func WithPostgresMultipleSchema added in v0.1.3

func WithPostgresMultipleSchema(schemaNameList ...string) Option

default dsn is postgres.dsn in *.toml

type Ormx

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

func New

func New(conf *configx.Configx, logCli logx.Logger, ops ...Option) (*Ormx, error)

New new Ormx with mysql default tableNamePrefix empty

func (*Ormx) Close

func (c *Ormx) Close(ctx context.Context, wg *sync.WaitGroup)

func (*Ormx) GetDB

func (c *Ormx) GetDB(projectName ...string) *gorm.DB

func (*Ormx) Name

func (c *Ormx) Name() string

Jump to

Keyboard shortcuts

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