dalgorm

package
v0.14.0-alpha8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dalgorm

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

Dalgorm FIXME ...

func NewDalgorm

func NewDalgorm(db *gorm.DB) *Dalgorm

NewDalgorm FIXME ...

func (*Dalgorm) AddColumn added in v0.14.0

func (d *Dalgorm) AddColumn(table, columnName, columnType string) errors.Error

AddColumn add one column for the table

func (*Dalgorm) All

func (d *Dalgorm) All(dst interface{}, clauses ...dal.Clause) errors.Error

All loads matched rows from database to `dst`, USE IT WITH COUTIOUS!!

func (*Dalgorm) AllTables

func (d *Dalgorm) AllTables() ([]string, errors.Error)

AllTables returns all tables in the database

func (*Dalgorm) AutoMigrate

func (d *Dalgorm) AutoMigrate(entity interface{}, clauses ...dal.Clause) errors.Error

AutoMigrate runs auto migration for given models

func (*Dalgorm) Count

func (d *Dalgorm) Count(clauses ...dal.Clause) (int64, errors.Error)

Count total records

func (*Dalgorm) Create

func (d *Dalgorm) Create(entity interface{}, clauses ...dal.Clause) errors.Error

Create insert record to database

func (*Dalgorm) CreateIfNotExist

func (d *Dalgorm) CreateIfNotExist(entity interface{}, clauses ...dal.Clause) errors.Error

CreateIfNotExist tries to create the record if not exist

func (*Dalgorm) CreateOrUpdate

func (d *Dalgorm) CreateOrUpdate(entity interface{}, clauses ...dal.Clause) errors.Error

CreateOrUpdate tries to create the record, or fallback to update all if failed

func (*Dalgorm) Cursor

func (d *Dalgorm) Cursor(clauses ...dal.Clause) (*sql.Rows, errors.Error)

Cursor returns a database cursor, cursor is especially useful when handling big amount of rows of data

func (*Dalgorm) CursorTx

func (d *Dalgorm) CursorTx(clauses ...dal.Clause) *gorm.DB

CursorTx FIXME ...

func (*Dalgorm) Delete

func (d *Dalgorm) Delete(entity interface{}, clauses ...dal.Clause) errors.Error

Delete records from database

func (*Dalgorm) DropColumn added in v0.14.0

func (d *Dalgorm) DropColumn(table, columnName string) errors.Error

DropColumn drop one column from the table

func (*Dalgorm) DropTable

func (d *Dalgorm) DropTable(dst ...interface{}) errors.Error

DropTable drop the table

func (*Dalgorm) Exec

func (d *Dalgorm) Exec(query string, params ...interface{}) errors.Error

Exec executes raw sql query

func (*Dalgorm) Fetch

func (d *Dalgorm) Fetch(cursor *sql.Rows, dst interface{}) errors.Error

Fetch loads row data from `cursor` into `dst`

func (*Dalgorm) First

func (d *Dalgorm) First(dst interface{}, clauses ...dal.Clause) errors.Error

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 schema.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) Pluck

func (d *Dalgorm) Pluck(column string, dest interface{}, clauses ...dal.Clause) errors.Error

Pluck used to query single column

func (*Dalgorm) RawCursor

func (d *Dalgorm) RawCursor(query string, params ...interface{}) (*sql.Rows, errors.Error)

RawCursor executes raw sql query and returns a database cursor

func (*Dalgorm) RenameTable added in v0.15.0

func (d *Dalgorm) RenameTable(oldName interface{}, newName interface{}) errors.Error

RenameTable rename the oldName table to newName

func (*Dalgorm) Update

func (d *Dalgorm) Update(entity interface{}, clauses ...dal.Clause) errors.Error

Update updates record

func (*Dalgorm) UpdateColumns added in v0.14.0

func (d *Dalgorm) UpdateColumns(entity interface{}, clauses ...dal.Clause) errors.Error

UpdateColumns batch records in database

Jump to

Keyboard shortcuts

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