Documentation ¶
Index ¶
- func Init(encryptionSecret string)
- func ToDatabaseMap(tableName string, m map[string]any) map[string]any
- type ColumnType
- type Dalgorm
- func (d *Dalgorm) AddColumn(table, columnName string, columnType dal.ColumnType) errors.Error
- func (d *Dalgorm) All(dst interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) AllTables() ([]string, errors.Error)
- func (d *Dalgorm) AutoMigrate(entity interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) Begin() dal.Transaction
- func (d *Dalgorm) Count(clauses ...dal.Clause) (int64, errors.Error)
- func (d *Dalgorm) Create(entity interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) CreateIfNotExist(entity interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) CreateOrUpdate(entity interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) CreateWithMap(entity interface{}, record map[string]interface{}) errors.Error
- func (d *Dalgorm) Cursor(clauses ...dal.Clause) (dal.Rows, errors.Error)
- func (d *Dalgorm) CursorTx(clauses ...dal.Clause) *gorm.DB
- func (d *Dalgorm) Delete(entity interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) Dialect() string
- func (d *Dalgorm) DropColumns(table string, columnNames ...string) errors.Error
- func (d *Dalgorm) DropIndexes(table string, indexNames ...string) errors.Error
- func (d *Dalgorm) DropTables(dst ...interface{}) errors.Error
- func (d *Dalgorm) Exec(query string, params ...interface{}) errors.Error
- func (d *Dalgorm) Fetch(cursor dal.Rows, dst interface{}) errors.Error
- func (d *Dalgorm) First(dst interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) GetColumns(dst dal.Tabler, filter func(columnMeta dal.ColumnMeta) bool) (cms []dal.ColumnMeta, _ errors.Error)
- func (d *Dalgorm) GetPrimaryKeyFields(t reflect.Type) []reflect.StructField
- func (d *Dalgorm) HasColumn(table interface{}, columnName string) bool
- func (d *Dalgorm) HasTable(table interface{}) bool
- func (d *Dalgorm) IsDuplicationError(err error) bool
- func (d *Dalgorm) IsErrorNotFound(err error) bool
- func (d *Dalgorm) Pluck(column string, dest interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) RawCursor(query string, params ...interface{}) (*sql.Rows, errors.Error)
- func (d *Dalgorm) RenameColumn(table, oldColumnName, newColumnName string) errors.Error
- func (d *Dalgorm) RenameTable(oldName, newName string) errors.Error
- func (d *Dalgorm) Session(config dal.SessionConfig) dal.Dal
- func (d *Dalgorm) Update(entity interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) UpdateAllColumn(entity interface{}, clauses ...dal.Clause) errors.Error
- func (d *Dalgorm) UpdateColumn(entityOrTable interface{}, columnName string, value interface{}, ...) errors.Error
- func (d *Dalgorm) UpdateColumns(entityOrTable interface{}, set []dal.DalSet, clauses ...dal.Clause) errors.Error
- type DalgormTransaction
- type EncDecSerializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ColumnType ¶
type ColumnType string
const ( Varchar ColumnType = "varchar(255)" Text ColumnType = "text" Int ColumnType = "bigint" Time ColumnType = "timestamp" Float ColumnType = "float" )
func (ColumnType) String ¶
func (c ColumnType) String() string
type Dalgorm ¶
type Dalgorm struct {
// contains filtered or unexported fields
}
Dalgorm implements the dal.Dal interface with gorm
func (*Dalgorm) AutoMigrate ¶
AutoMigrate runs auto migration for given models
func (*Dalgorm) CreateIfNotExist ¶
CreateIfNotExist tries to create the record if not exist
func (*Dalgorm) CreateOrUpdate ¶
CreateOrUpdate tries to create the record, or fallback to update all if failed
func (*Dalgorm) CreateWithMap ¶
CreateWithMap insert record to database
func (*Dalgorm) Cursor ¶
Cursor returns a database cursor, cursor is especially useful when handling big amount of rows of data
func (*Dalgorm) DropColumns ¶
DropColumns drop one column from the table
func (*Dalgorm) DropIndexes ¶
DropIndexes drops indexes for specified table
func (*Dalgorm) DropTables ¶
DropTables drop multiple tables by Model Pointer or Table Name
func (*Dalgorm) First ¶
First loads first matched row from database to `dst`, error will be returned if no records were found
func (*Dalgorm) GetColumns ¶
func (d *Dalgorm) GetColumns(dst dal.Tabler, filter func(columnMeta dal.ColumnMeta) bool) (cms []dal.ColumnMeta, _ errors.Error)
GetColumns FIXME ...
func (*Dalgorm) GetPrimaryKeyFields ¶
func (d *Dalgorm) GetPrimaryKeyFields(t reflect.Type) []reflect.StructField
GetPrimaryKeyFields get the PrimaryKey from `gorm` tag
func (*Dalgorm) IsDuplicationError ¶
IsDuplicationError checking if the sql error is not found.
func (*Dalgorm) IsErrorNotFound ¶
IsErrorNotFound checking if the sql error is not found.
func (*Dalgorm) RawCursor ¶
RawCursor (Deprecated) executes raw sql query and returns a database cursor
func (*Dalgorm) RenameColumn ¶
RenameColumn renames column name for specified table
func (*Dalgorm) RenameTable ¶
RenameTable renames table name
func (*Dalgorm) Session ¶
func (d *Dalgorm) Session(config dal.SessionConfig) dal.Dal
Session creates a new manual transaction for special scenarios
func (*Dalgorm) UpdateAllColumn ¶
UpdateAllColumn updated all Columns of entity
type DalgormTransaction ¶
type DalgormTransaction struct {
*Dalgorm
}
DalgormTransaction represents a gorm transaction which using the same underlying session for all queries
func (*DalgormTransaction) Commit ¶
func (t *DalgormTransaction) Commit() errors.Error
Commit the transaction
func (*DalgormTransaction) Rollback ¶
func (t *DalgormTransaction) Rollback() errors.Error
Rollback the transaction
type EncDecSerializer ¶
type EncDecSerializer struct {
// contains filtered or unexported fields
}
EncDecSerializer is responsible for field encryption/decryption in Application Level Ref: https://gorm.io/docs/serializer.html