db

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-23 13:05:48 * @FilePath: \go-sqlbuilder\db\handler.go * @Description: 数据库处理器 - Handler 接口和 GORM 实现 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormHandler

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

GormHandler 标准 GORM 处理器实现

func (*GormHandler) GetDB added in v0.1.7

func (h *GormHandler) GetDB() *gorm.DB

DB 返回底层 GORM 实例

func (*GormHandler) IsConnected added in v0.1.7

func (h *GormHandler) IsConnected() bool

IsConnected 检查数据库连接是否有效

type Handler

type Handler interface {
	// GetDB 返回 GORM 数据库实例
	GetDB() *gorm.DB

	// IsConnected 检查数据库连接是否有效
	IsConnected() bool
}

Handler 数据库处理器接口 所有 Repository 都基于这个接口工作,提供统一的数据库访问抽象

func MustNewGormHandler added in v0.1.7

func MustNewGormHandler(db *gorm.DB) Handler

MustNewGormHandler 创建 GORM 处理器(panic 版本) 仅在确定 db 不为 nil 时使用,通常用于初始化阶段

func NewGormHandler

func NewGormHandler(db *gorm.DB) (Handler, error)

NewGormHandler 创建 GORM 处理器 返回 Handler 接口和可能的错误

Jump to

Keyboard shortcuts

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