dao

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditColumns

type AuditColumns struct {
	Id        string // self increasing id
	Module    string // module
	Event     string // event name
	From      string // identity
	Content   string // content
	CreatedAt string // created_at
}

AuditColumns defines and stores column names for table audit.

type AuditDao

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

AuditDao is the data access object for table audit.

func NewAuditDao

func NewAuditDao(db gdb.DB, table string) *AuditDao

NewAuditDao creates and returns a new DAO object for table data access.

func (*AuditDao) Columns

func (dao *AuditDao) Columns() AuditColumns

Columns returns all column names of current dao.

func (*AuditDao) Ctx

func (dao *AuditDao) Ctx(ctx context.Context) *gdb.Model

Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.

func (*AuditDao) DB

func (dao *AuditDao) DB() gdb.DB

DB retrieves and returns the underlying raw database management object of current DAO.

func (*AuditDao) Group

func (dao *AuditDao) Group() string

Group returns the configuration group name of database of current dao.

func (*AuditDao) Table

func (dao *AuditDao) Table() string

Table returns the table name of current dao.

func (*AuditDao) Transaction

func (dao *AuditDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error)

Transaction wraps the transaction logic using function f. It rollbacks the transaction and returns the error from function f if it returns non-nil error. It commits the transaction and returns nil if function f returns nil.

Note that, you should not Commit or Rollback the transaction in function f as it is automatically handled by this function.

Jump to

Keyboard shortcuts

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