db

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetCat           GetName       = "GetCat"
	QueryCat         QueryName     = "QueryCat"
	AddCat           AddName       = "AddCat"
	UpdateCat        UpdateName    = "UpdateCat"
	DeleteCat        DeleteName    = "DeleteCat"
	GetCompany       GetName       = "GetCompany"
	QueryCompany     QueryName     = "QueryCompany"
	AddCompany       AddName       = "AddCompany"
	UpdateCompany    UpdateName    = "UpdateCompany"
	DeleteCompany    DeleteName    = "DeleteCompany"
	GetSmartPhone    GetName       = "GetSmartPhone"
	QuerySmartPhone  QueryName     = "QuerySmartPhone"
	AddSmartPhone    AddName       = "AddSmartPhone"
	UpdateSmartPhone UpdateName    = "UpdateSmartPhone"
	DeleteSmartPhone DeleteName    = "DeleteSmartPhone"
	AddUser2Todos    Many2ManyName = "AddUser2Todos"
	GetTodo          GetName       = "GetTodo"
	QueryTodo        QueryName     = "QueryTodo"
	AddTodo          AddName       = "AddTodo"
	UpdateTodo       UpdateName    = "UpdateTodo"
	DeleteTodo       DeleteName    = "DeleteTodo"
	GetUser          GetName       = "GetUser"
	QueryUser        QueryName     = "QueryUser"
	AddUser          AddName       = "AddUser"
	UpdateUser       UpdateName    = "UpdateUser"
	DeleteUser       DeleteName    = "DeleteUser"
)

Variables

This section is empty.

Functions

func AddAddHook

func AddAddHook[M AutoGqlHookM, I AutoGqlHookI, AP AutoGqlHookAP](db *AutoGqlDB, name AddName, implementation AutoGqlHookAdd[M, I, AP])

func AddDeleteHook

func AddDeleteHook[F AutoGqlHookF, DP AutoGqlHookDP](db *AutoGqlDB, name DeleteName, implementation AutoGqlHookDelete[F, DP])

func AddGetHook

func AddGetHook[T AutoGqlHookM, I any](db *AutoGqlDB, name GetName, implementation AutoGqlHookGet[T, I])

func AddMany2ManyHook

func AddMany2ManyHook[U AutoGqlHookM2M, UP AutoGqlHookUP](db *AutoGqlDB, name Many2ManyName, implementation AutoGqlHookMany2Many[U, UP])

func AddQueryHook

func AddQueryHook[M AutoGqlHookM, F AutoGqlHookF, O AutoGqlHookQueryO](db *AutoGqlDB, name QueryName, implementation AutoGqlHookQuery[M, F, O])

func AddUpdateHook

func AddUpdateHook[M AutoGqlHookM, U AutoGqlHookU, UP AutoGqlHookUP](db *AutoGqlDB, name UpdateName, implementation AutoGqlHookUpdate[U, UP])

Types

type AddName

type AddName string

type AutoGqlDB

type AutoGqlDB struct {
	Db    *gorm.DB
	Hooks map[string]any
}

func NewAutoGqlDB

func NewAutoGqlDB(db *gorm.DB) AutoGqlDB

func (*AutoGqlDB) Init

func (db *AutoGqlDB) Init()

type AutoGqlHookAdd

type AutoGqlHookAdd[obj AutoGqlHookM, input AutoGqlHookI, res AutoGqlHookAP] interface {
	Received(ctx context.Context, dbHelper *AutoGqlDB, input []*input) (*gorm.DB, []*input, error)
	BeforeCallDb(ctx context.Context, db *gorm.DB, data []obj) (*gorm.DB, []obj, error)
	BeforeReturn(ctx context.Context, db *gorm.DB, data []obj, res *res) (*res, error)
}

type AutoGqlHookDelete

type AutoGqlHookDelete[input AutoGqlHookF, res AutoGqlHookDP] interface {
	Received(ctx context.Context, dbHelper *AutoGqlDB, input *input) (*gorm.DB, input, error)
	BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error)
	BeforeReturn(ctx context.Context, db *gorm.DB, res *res) (*res, error)
}

type AutoGqlHookGet

type AutoGqlHookGet[obj AutoGqlHookM, identifier any] interface {
	Received(ctx context.Context, dbHelper *AutoGqlDB, id ...identifier) (*gorm.DB, error)
	BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error)
	AfterCallDb(ctx context.Context, data *obj) (*obj, error)
	BeforeReturn(ctx context.Context, data *obj, db *gorm.DB) (*obj, error)
}

type AutoGqlHookM

type AutoGqlHookM interface {
	model.Cat | model.Company | model.SmartPhone | model.Todo | model.User
}

type AutoGqlHookM2M

type AutoGqlHookM2M interface {
	model.UserRef2TodosInput
}

type AutoGqlHookMany2Many

type AutoGqlHookMany2Many[input AutoGqlHookM2M, res AutoGqlHookUP] interface {
	Received(ctx context.Context, dbHelper *AutoGqlDB, input *input) (*gorm.DB, input, error)
	BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error)
	BeforeReturn(ctx context.Context, db *gorm.DB, res *res) (*res, error)
}

type AutoGqlHookQuery

type AutoGqlHookQuery[obj AutoGqlHookM, filter AutoGqlHookF, order AutoGqlHookQueryO] interface {
	Received(ctx context.Context, dbHelper *AutoGqlDB, filter *filter, order *order, first, offset *int) (*gorm.DB, *filter, *order, *int, *int, error)
	BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error)
	AfterCallDb(ctx context.Context, data []*obj) ([]*obj, error)
	BeforeReturn(ctx context.Context, data []*obj, db *gorm.DB) ([]*obj, error)
}

type AutoGqlHookUpdate

type AutoGqlHookUpdate[input AutoGqlHookU, res AutoGqlHookUP] interface {
	Received(ctx context.Context, dbHelper *AutoGqlDB, input *input) (*gorm.DB, input, error)
	BeforeCallDb(ctx context.Context, db *gorm.DB, data map[string]interface{}) (*gorm.DB, map[string]interface{}, error)
	BeforeReturn(ctx context.Context, db *gorm.DB, res *res) (*res, error)
}

type DefaultAddHook

type DefaultAddHook[obj AutoGqlHookM, input AutoGqlHookI, res AutoGqlHookAP] struct{}

func (DefaultAddHook[obj, inputType, resType]) BeforeCallDb

func (d DefaultAddHook[obj, inputType, resType]) BeforeCallDb(ctx context.Context, db *gorm.DB, data []obj) (*gorm.DB, []obj, error)

func (DefaultAddHook[obj, inputType, resType]) BeforeReturn

func (d DefaultAddHook[obj, inputType, resType]) BeforeReturn(ctx context.Context, db *gorm.DB, data []obj, res *resType) (*resType, error)

func (DefaultAddHook[obj, inputType, resType]) Received

func (d DefaultAddHook[obj, inputType, resType]) Received(ctx context.Context, dbHelper *AutoGqlDB, input []*inputType) (*gorm.DB, []*inputType, error)

type DefaultDeleteHook

type DefaultDeleteHook[input AutoGqlHookF, res AutoGqlHookDP] struct{}

func (DefaultDeleteHook[inputType, resType]) BeforeCallDb

func (d DefaultDeleteHook[inputType, resType]) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error)

func (DefaultDeleteHook[inputType, resType]) BeforeReturn

func (d DefaultDeleteHook[inputType, resType]) BeforeReturn(ctx context.Context, db *gorm.DB, res *resType) (*resType, error)

func (DefaultDeleteHook[inputType, resType]) Received

func (d DefaultDeleteHook[inputType, resType]) Received(ctx context.Context, dbHelper *AutoGqlDB, input *inputType) (*gorm.DB, inputType, error)

type DefaultGetHook

type DefaultGetHook[obj AutoGqlHookM, identifier any] struct{}

func (DefaultGetHook[obj, identifier]) AfterCallDb

func (d DefaultGetHook[obj, identifier]) AfterCallDb(ctx context.Context, data *obj) (*obj, error)

func (DefaultGetHook[obj, identifier]) BeforeCallDb

func (d DefaultGetHook[obj, identifier]) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error)

func (DefaultGetHook[obj, identifier]) BeforeReturn

func (d DefaultGetHook[obj, identifier]) BeforeReturn(ctx context.Context, data *obj, db *gorm.DB) (*obj, error)

func (DefaultGetHook[obj, identifier]) Received

func (d DefaultGetHook[obj, identifier]) Received(ctx context.Context, dbHelper *AutoGqlDB, id ...identifier) (*gorm.DB, error)

type DefaultMany2ManyHook

type DefaultMany2ManyHook[input AutoGqlHookM2M, res AutoGqlHookUP] struct{}

func (DefaultMany2ManyHook[inputType, resType]) BeforeCallDb

func (d DefaultMany2ManyHook[inputType, resType]) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error)

func (DefaultMany2ManyHook[inputType, resType]) BeforeReturn

func (d DefaultMany2ManyHook[inputType, resType]) BeforeReturn(ctx context.Context, db *gorm.DB, res *resType) (*resType, error)

func (DefaultMany2ManyHook[inputType, resType]) Received

func (d DefaultMany2ManyHook[inputType, resType]) Received(ctx context.Context, dbHelper *AutoGqlDB, input *inputType) (*gorm.DB, inputType, error)

type DefaultQueryHook

type DefaultQueryHook[obj AutoGqlHookM, filter AutoGqlHookF, order AutoGqlHookQueryO] struct{}

func (DefaultQueryHook[obj, filter, order]) AfterCallDb

func (d DefaultQueryHook[obj, filter, order]) AfterCallDb(ctx context.Context, data []*obj) ([]*obj, error)

func (DefaultQueryHook[obj, filter, order]) BeforeCallDb

func (d DefaultQueryHook[obj, filter, order]) BeforeCallDb(ctx context.Context, db *gorm.DB) (*gorm.DB, error)

func (DefaultQueryHook[obj, filter, order]) BeforeReturn

func (d DefaultQueryHook[obj, filter, order]) BeforeReturn(ctx context.Context, data []*obj, db *gorm.DB) ([]*obj, error)

func (DefaultQueryHook[obj, filterType, orderType]) Received

func (d DefaultQueryHook[obj, filterType, orderType]) Received(ctx context.Context, dbHelper *AutoGqlDB, filter *filterType, order *orderType, first, offset *int) (*gorm.DB, *filterType, *orderType, *int, *int, error)

type DefaultUpdateHook

type DefaultUpdateHook[input AutoGqlHookU, res AutoGqlHookUP] struct{}

func (DefaultUpdateHook[inputType, resType]) BeforeCallDb

func (d DefaultUpdateHook[inputType, resType]) BeforeCallDb(ctx context.Context, db *gorm.DB, data map[string]interface{}) (*gorm.DB, map[string]interface{}, error)

func (DefaultUpdateHook[inputType, resType]) BeforeReturn

func (d DefaultUpdateHook[inputType, resType]) BeforeReturn(ctx context.Context, db *gorm.DB, res *resType) (*resType, error)

func (DefaultUpdateHook[inputType, resType]) Received

func (d DefaultUpdateHook[inputType, resType]) Received(ctx context.Context, dbHelper *AutoGqlDB, input *inputType) (*gorm.DB, inputType, error)

type DeleteName

type DeleteName string

type GetName

type GetName string

type Many2ManyName

type Many2ManyName string

type QueryName

type QueryName string

type UpdateName

type UpdateName string

Jump to

Keyboard shortcuts

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