record

package
v0.0.1-20220809-0008 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeSave   = "save"
	ModeCreate = "create"
)

Variables

This section is empty.

Functions

func GetInterfacePointer

func GetInterfacePointer(obj interface{}) interface{}

Types

type Record

type Record struct {
	// This is the model which the user has set, after that is the model from which we read back the data!
	// it should be with pointer address
	//NonPtrObj interface{}
	// ================== INPUT DATA ===================\\
	// Data -> can be a map[string]interface{} or a real any Struct from where we will copy the data!
	Data interface{}

	// ================== MODEL STRUCTURE ===================\\
	// this is the structure of the set NonPtrObj, it's a pointer!
	ModelStruct interface{}

	// AutoLoad -> should auto load the data if it's an existing record
	// TODO: posibil ca acesta nu trebuie sa lucreze in module in care noi cerem datele de la DB apoi facem merge, si apoi
	// actualizam..., ar trebui invers sa facem... sa actualizam doar diferenta in DB, apoi sa cerem record-ul, si apoi
	// sa vedem ce schimbari au fost facute... insa intrebarea consta in aceea -> DAR CARE A FOST OLD RECORD?!
	// Db-ul nu ne raspunde cu astfel de informatie..., de aceea totusi este necesar sa incarcam mai intii informatia
	// aici in memorie si apoi sa actualizam DB doar cu diferenta! diferenta e Input Data!
	// noi am putea sa folosim acelasi input data ca saveData si sa indicam denumirea tabelului manual....
	// sau GORM automat face diferenta?!!
	AutoLoad bool

	Ctx context.Context
	DB  *gorm.DB

	// You can specify: save,create,insert,update
	SaveMode string
	// contains filtered or unexported fields
}

func New

func New(r *Record) *Record

func (*Record) Delete

func (r *Record) Delete() bool

func (*Record) Exists

func (r *Record) Exists() (bool, error)

func (*Record) ForceDelete

func (r *Record) ForceDelete() bool

ForceDelete -> it will completely delete the record from the DB

func (*Record) GetDBFieldName

func (r *Record) GetDBFieldName(fieldName string) string

func (*Record) GetDeviceID

func (r *Record) GetDeviceID() interface{}

func (*Record) GetInputFieldValue

func (r *Record) GetInputFieldValue(fieldName string) (interface{}, error)

GetInputFieldValue -> will return the value that has been set!

func (*Record) GetLastDBError

func (r *Record) GetLastDBError() error

func (*Record) GetLastError

func (r *Record) GetLastError() error

func (*Record) GetLoadedData

func (r *Record) GetLoadedData() interface{}

func (*Record) GetOmitFields

func (r *Record) GetOmitFields() []string

func (*Record) GetSaveData

func (r *Record) GetSaveData() interface{}

func (r *Record) GetSaveData() map[string]interface{} {

func (*Record) GetSavedData

func (r *Record) GetSavedData() interface{}

func (*Record) GetUserID

func (r *Record) GetUserID() interface{}

func (*Record) IsCreateMode

func (r *Record) IsCreateMode() bool

func (*Record) IsDBError

func (r *Record) IsDBError() bool

func (*Record) IsLoadDataOk

func (r *Record) IsLoadDataOk() bool

func (*Record) IsRecordFound

func (r *Record) IsRecordFound() bool

func (*Record) IsRecordNotFound

func (r *Record) IsRecordNotFound() bool

func (*Record) IsSaveMode

func (r *Record) IsSaveMode() bool

func (*Record) IsStructFieldExists

func (r *Record) IsStructFieldExists(fieldName string) bool

func (*Record) LoadData

func (r *Record) LoadData() (status bool)

LoadData -> from the db, it loads the data if exists, if it doesn't exist then it return true!

func (*Record) PreparePrimaryKeys

func (r *Record) PreparePrimaryKeys()

func (*Record) ReloadData

func (r *Record) ReloadData() bool

ReloadData -> it will forcefully reload the data

func (*Record) RemoveOmitField

func (r *Record) RemoveOmitField(fieldName string)

func (*Record) Save

func (r *Record) Save() bool

func (*Record) SetDeviceID

func (r *Record) SetDeviceID(deviceID interface{}) *Record

func (*Record) SetOmitField

func (r *Record) SetOmitField(fieldName string)

func (*Record) SetSaveData

func (r *Record) SetSaveData(saveData interface{}) *Record

func (r *Record) SetSaveData(saveData map[string]interface{}) *Record {

func (*Record) SetSaveFieldValue

func (r *Record) SetSaveFieldValue(fieldName string, value interface{})

func (*Record) SetUserID

func (r *Record) SetUserID(userID interface{}) *Record

Jump to

Keyboard shortcuts

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