crud

package
v0.0.0-...-8122643 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(crud CRUD, ctx op_context.Context, methodName string, obj common.Object, loggerFields ...logger.Fields) error

func Delete

func Delete(crud CRUD, ctx op_context.Context, methodName string, fieldName string, fieldValue interface{}, object common.Object, loggerFields ...logger.Fields) error

func DeleteByFields

func DeleteByFields(crud CRUD, ctx op_context.Context, methodName string, fields db.Fields, object common.Object, loggerFields ...logger.Fields) error

func Exists

func Exists(crud CRUD, ctx op_context.Context, methodName string, filter *db.Filter, object interface{}) (bool, error)

func Find

func Find[T common.Object](crud CRUD, ctx op_context.Context, methodName string, fields db.Fields, object T, dest ...interface{}) (T, error)

func FindByField

func FindByField[T common.Object](crud CRUD, ctx op_context.Context, methodName string, fieldName string, fieldValue interface{}, object T, dest ...interface{}) (T, error)

func FindOne

func FindOne[T common.Object](crud CRUD, ctx op_context.Context, filter *db.Filter, model T) (T, error)

func FindUpdate

func FindUpdate[T common.Object](crud CRUD, ctx op_context.Context, methodName string, fieldName string, fieldValue interface{}, fields db.Fields, object T, dest ...interface{}) (T, error)

func List

func List[T common.Object](crud CRUD, ctx op_context.Context, methodName string, filter *db.Filter, objects *[]T, dest ...interface{}) (int64, error)

func Update

func Update(crud CRUD, ctx op_context.Context, methodName string, obj common.Object, fields db.Fields, loggerFields ...logger.Fields) error

Types

type CRUD

type CRUD interface {
	Create(ctx op_context.Context, object common.Object) error
	CreateDup(ctx op_context.Context, object common.Object, ignoreConflict ...bool) (bool, error)

	Read(ctx op_context.Context, fields db.Fields, object interface{}, dest ...interface{}) (bool, error)
	ReadByField(ctx op_context.Context, fieldName string, fieldValue interface{}, object interface{}, dest ...interface{}) (bool, error)
	ReadForUpdate(ctx op_context.Context, fields db.Fields, object interface{}) (bool, error)
	ReadForShare(ctx op_context.Context, fields db.Fields, object interface{}) (bool, error)
	Update(ctx op_context.Context, object common.Object, fields db.Fields) error
	UpdateMonthObject(ctx op_context.Context, obj common.ObjectWithMonth, fields db.Fields) error
	UpdateMulti(ctx op_context.Context, model interface{}, filter db.Fields, fields db.Fields) error
	UpdateWithFilter(ctx op_context.Context, model interface{}, filter *db.Filter, fields db.Fields) error
	Delete(ctx op_context.Context, object common.Object) error
	DeleteByFields(ctx op_context.Context, field db.Fields, object common.Object) error

	List(ctx op_context.Context, filter *db.Filter, object interface{}, dest ...interface{}) (int64, error)
	Exists(ctx op_context.Context, filter *db.Filter, object interface{}) (bool, error)

	Join(ctx op_context.Context, joinConfig *db.JoinQueryConfig, filter *db.Filter, dest interface{}) (int64, error)

	Db(ctx op_context.Context) db.DBHandlers
}

type DbCRUD

type DbCRUD struct {
	ForceMainDb bool
	DryRun      bool
}

func (*DbCRUD) Create

func (d *DbCRUD) Create(ctx op_context.Context, object common.Object) error

func (*DbCRUD) CreateDup

func (d *DbCRUD) CreateDup(ctx op_context.Context, object common.Object, ignoreConflict ...bool) (bool, error)

func (*DbCRUD) Db

func (d *DbCRUD) Db(ctx op_context.Context) db.DBHandlers

func (*DbCRUD) Delete

func (d *DbCRUD) Delete(ctx op_context.Context, object common.Object) error

func (*DbCRUD) DeleteByFields

func (d *DbCRUD) DeleteByFields(ctx op_context.Context, fields db.Fields, object common.Object) error

func (*DbCRUD) Exists

func (d *DbCRUD) Exists(ctx op_context.Context, filter *db.Filter, object interface{}) (bool, error)

func (*DbCRUD) Join

func (d *DbCRUD) Join(ctx op_context.Context, joinConfig *db.JoinQueryConfig, filter *db.Filter, dest interface{}) (int64, error)

func (*DbCRUD) List

func (d *DbCRUD) List(ctx op_context.Context, filter *db.Filter, objects interface{}, dest ...interface{}) (int64, error)

func (*DbCRUD) Read

func (d *DbCRUD) Read(ctx op_context.Context, fields db.Fields, object interface{}, dest ...interface{}) (bool, error)

func (*DbCRUD) ReadByField

func (d *DbCRUD) ReadByField(ctx op_context.Context, fieldName string, fieldValue interface{}, object interface{}, dest ...interface{}) (bool, error)

func (*DbCRUD) ReadForShare

func (d *DbCRUD) ReadForShare(ctx op_context.Context, fields db.Fields, object interface{}) (bool, error)

func (*DbCRUD) ReadForUpdate

func (d *DbCRUD) ReadForUpdate(ctx op_context.Context, fields db.Fields, object interface{}) (bool, error)

func (*DbCRUD) Update

func (d *DbCRUD) Update(ctx op_context.Context, obj common.Object, fields db.Fields) error

func (*DbCRUD) UpdateMonthObject

func (d *DbCRUD) UpdateMonthObject(ctx op_context.Context, obj common.ObjectWithMonth, fields db.Fields) error

func (*DbCRUD) UpdateMulti

func (d *DbCRUD) UpdateMulti(ctx op_context.Context, model interface{}, filter db.Fields, fields db.Fields) error

func (*DbCRUD) UpdateWithFilter

func (d *DbCRUD) UpdateWithFilter(ctx op_context.Context, model interface{}, filter *db.Filter, fields db.Fields) error

type WithCRUD

type WithCRUD interface {
	CRUD() CRUD
}

type WithCRUDBase

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

func (*WithCRUDBase) CRUD

func (w *WithCRUDBase) CRUD() CRUD

func (*WithCRUDBase) Construct

func (w *WithCRUDBase) Construct(cruds ...CRUD)

func (*WithCRUDBase) IsDryRun

func (w *WithCRUDBase) IsDryRun() bool

func (*WithCRUDBase) IsForceMainDb

func (w *WithCRUDBase) IsForceMainDb() bool

func (*WithCRUDBase) SetDryRun

func (w *WithCRUDBase) SetDryRun(enable bool)

func (*WithCRUDBase) SetForceMainDb

func (w *WithCRUDBase) SetForceMainDb(enable bool)

Jump to

Keyboard shortcuts

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