Documentation ¶
Overview ¶
generated by stacks/gong/go/models/orm_file_per_struct_back_repo.go
do not modify, generated file
generated code - do not edit
generated code - do not edit
generated code - do not edit
generated code - do not edit
generated code - do not edit
Index ¶
- Variables
- func CopyBackRepoToBackRepoData(backRepo *BackRepoStruct, backRepoData *BackRepoData)
- func GetID[T models.Gongstruct](stage *models.StageStruct, backRepo *BackRepoStruct, instance *T) (id int)
- func GetIDPointer[T models.PointerToGongstruct](stage *models.StageStruct, backRepo *BackRepoStruct, instance T) (id int)
- func GetInstanceDBFromInstance[T models.Gongstruct, T2 GongstructDB](stage *models.StageStruct, backRepo *BackRepoStruct, instance *T) (ret *T2)
- func GetReverseFieldOwner[T models.Gongstruct](stage *models.StageStruct, backRepo *BackRepoStruct, instance *T, ...) (res any)
- func GetReverseFieldOwnerName[T models.Gongstruct](stage *models.StageStruct, backRepo *BackRepoStruct, instance *T, ...) (res string)
- type BackRepoContentStruct
- func (backRepoContent *BackRepoContentStruct) Backup(dirPath string)
- func (backRepoContent *BackRepoContentStruct) BackupXL(file *xlsx.File)
- func (backRepoContent *BackRepoContentStruct) CheckoutPhaseOne() (Error error)
- func (backRepoContent *BackRepoContentStruct) CheckoutPhaseOneInstance(contentDB *ContentDB) (Error error)
- func (backRepoContent *BackRepoContentStruct) CheckoutPhaseTwo(backRepo *BackRepoStruct) (Error error)
- func (backRepoContent *BackRepoContentStruct) CheckoutPhaseTwoInstance(backRepo *BackRepoStruct, contentDB *ContentDB) (Error error)
- func (backRepoContent *BackRepoContentStruct) CommitDeleteInstance(id uint) (Error error)
- func (backRepoContent *BackRepoContentStruct) CommitPhaseOne(stage *models.StageStruct) (Error error)
- func (backRepoContent *BackRepoContentStruct) CommitPhaseOneInstance(content *models.Content) (Error error)
- func (backRepoContent *BackRepoContentStruct) CommitPhaseTwo(backRepo *BackRepoStruct) (Error error)
- func (backRepoContent *BackRepoContentStruct) CommitPhaseTwoInstance(backRepo *BackRepoStruct, idx uint, content *models.Content) (Error error)
- func (backRepoContent *BackRepoContentStruct) GetContentDBFromContentPtr(content *models.Content) (contentDB *ContentDB)
- func (backRepoContent *BackRepoContentStruct) GetDB() db.DBInterface
- func (backRepoContent *BackRepoContentStruct) GetStage() (stage *models.StageStruct)
- func (backRepoContent *BackRepoContentStruct) ResetReversePointers(backRepo *BackRepoStruct) (Error error)
- func (backRepoContent *BackRepoContentStruct) ResetReversePointersInstance(backRepo *BackRepoStruct, idx uint, content *models.Content) (Error error)
- func (backRepoContent *BackRepoContentStruct) RestorePhaseOne(dirPath string)
- func (backRepoContent *BackRepoContentStruct) RestorePhaseTwo()
- func (backRepoContent *BackRepoContentStruct) RestoreXLPhaseOne(file *xlsx.File)
- type BackRepoData
- type BackRepoStruct
- func (backRepo *BackRepoStruct) Backup(stage *models.StageStruct, dirPath string)
- func (backRepo *BackRepoStruct) BackupXL(stage *models.StageStruct, dirPath string)
- func (backRepo *BackRepoStruct) Checkout(stage *models.StageStruct)
- func (backRepo *BackRepoStruct) CheckoutContent(content *models.Content)
- func (backRepo *BackRepoStruct) Commit(stage *models.StageStruct)
- func (backRepo *BackRepoStruct) CommitContent(content *models.Content)
- func (backRepo *BackRepoStruct) GetLastCommitFromBackNb() uint
- func (backRepo *BackRepoStruct) GetLastPushFromFrontNb() uint
- func (backRepo *BackRepoStruct) GetStage() (stage *models.StageStruct)
- func (backRepo *BackRepoStruct) IncrementCommitFromBackNb() uint
- func (backRepo *BackRepoStruct) IncrementPushFromFrontNb() uint
- func (backRepo *BackRepoStruct) Restore(stage *models.StageStruct, dirPath string)
- func (backRepo *BackRepoStruct) RestoreXL(stage *models.StageStruct, dirPath string)
- func (backRepoStruct *BackRepoStruct) SubscribeToCommitNb(ctx context.Context) <-chan int
- type ContentAPI
- type ContentDB
- func (contentDB *ContentDB) CopyBasicFieldsFromContent(content *models.Content)
- func (contentDB *ContentDB) CopyBasicFieldsFromContentWOP(content *ContentWOP)
- func (contentDB *ContentDB) CopyBasicFieldsFromContent_WOP(content *models.Content_WOP)
- func (contentDB *ContentDB) CopyBasicFieldsToContent(content *models.Content)
- func (contentDB *ContentDB) CopyBasicFieldsToContentWOP(content *ContentWOP)
- func (contentDB *ContentDB) CopyBasicFieldsToContent_WOP(content *models.Content_WOP)
- func (contentDB *ContentDB) DecodePointers(backRepo *BackRepoStruct, content *models.Content)
- type ContentDBResponse
- type ContentDBs
- type ContentPointersEncoding
- type ContentWOP
- type DBLite
- func (db *DBLite) Create(instanceDB any) (db.DBInterface, error)
- func (db *DBLite) Delete(instanceDB any) (db.DBInterface, error)
- func (db *DBLite) Find(instanceDBs any) (db.DBInterface, error)
- func (db *DBLite) First(instanceDB any, conds ...any) (db.DBInterface, error)
- func (db *DBLite) Model(instanceDB any) (db.DBInterface, error)
- func (db *DBLite) Save(instanceDB any) (db.DBInterface, error)
- func (db *DBLite) Unscoped() (db.DBInterface, error)
- func (db *DBLite) Updates(instanceDB any) (db.DBInterface, error)
- type GongstructDB
- type IntSlice
Constants ¶
This section is empty.
Variables ¶
var BackRepoContentid_atBckpTime_newID map[uint]uint
this field is used during the restauration process. it stores the ID at the backup time and is used for renumbering
var Content_Fields = []string{
"ID",
"Name",
"Content",
}
Functions ¶
func CopyBackRepoToBackRepoData ¶
func CopyBackRepoToBackRepoData(backRepo *BackRepoStruct, backRepoData *BackRepoData)
func GetID ¶
func GetID[T models.Gongstruct]( stage *models.StageStruct, backRepo *BackRepoStruct, instance *T) (id int)
func GetIDPointer ¶
func GetIDPointer[T models.PointerToGongstruct]( stage *models.StageStruct, backRepo *BackRepoStruct, instance T) (id int)
func GetInstanceDBFromInstance ¶
func GetInstanceDBFromInstance[T models.Gongstruct, T2 GongstructDB]( stage *models.StageStruct, backRepo *BackRepoStruct, instance *T) (ret *T2)
func GetReverseFieldOwner ¶
func GetReverseFieldOwner[T models.Gongstruct]( stage *models.StageStruct, backRepo *BackRepoStruct, instance *T, reverseField *models.ReverseField) (res any)
func GetReverseFieldOwnerName ¶
func GetReverseFieldOwnerName[T models.Gongstruct]( stage *models.StageStruct, backRepo *BackRepoStruct, instance *T, reverseField *models.ReverseField) (res string)
Types ¶
type BackRepoContentStruct ¶
type BackRepoContentStruct struct { // stores ContentDB according to their gorm ID Map_ContentDBID_ContentDB map[uint]*ContentDB // stores ContentDB ID according to Content address Map_ContentPtr_ContentDBID map[*models.Content]uint // stores Content according to their gorm ID Map_ContentDBID_ContentPtr map[uint]*models.Content // contains filtered or unexported fields }
func (*BackRepoContentStruct) Backup ¶
func (backRepoContent *BackRepoContentStruct) Backup(dirPath string)
Backup generates a json file from a slice of all ContentDB instances in the backrepo
func (*BackRepoContentStruct) BackupXL ¶
func (backRepoContent *BackRepoContentStruct) BackupXL(file *xlsx.File)
Backup generates a json file from a slice of all ContentDB instances in the backrepo
func (*BackRepoContentStruct) CheckoutPhaseOne ¶
func (backRepoContent *BackRepoContentStruct) CheckoutPhaseOne() (Error error)
BackRepoContent.CheckoutPhaseOne Checkouts all BackRepo instances to the Stage
Phase One will result in having instances on the stage aligned with the back repo pointers are not initialized yet (this is for phase two)
func (*BackRepoContentStruct) CheckoutPhaseOneInstance ¶
func (backRepoContent *BackRepoContentStruct) CheckoutPhaseOneInstance(contentDB *ContentDB) (Error error)
CheckoutPhaseOneInstance takes a contentDB that has been found in the DB, updates the backRepo and stages the models version of the contentDB
func (*BackRepoContentStruct) CheckoutPhaseTwo ¶
func (backRepoContent *BackRepoContentStruct) CheckoutPhaseTwo(backRepo *BackRepoStruct) (Error error)
BackRepoContent.CheckoutPhaseTwo Checkouts all staged instances of Content to the BackRepo Phase Two is the update of instance with the field in the database
func (*BackRepoContentStruct) CheckoutPhaseTwoInstance ¶
func (backRepoContent *BackRepoContentStruct) CheckoutPhaseTwoInstance(backRepo *BackRepoStruct, contentDB *ContentDB) (Error error)
BackRepoContent.CheckoutPhaseTwoInstance Checkouts staged instances of Content to the BackRepo Phase Two is the update of instance with the field in the database
func (*BackRepoContentStruct) CommitDeleteInstance ¶
func (backRepoContent *BackRepoContentStruct) CommitDeleteInstance(id uint) (Error error)
BackRepoContent.CommitDeleteInstance commits deletion of Content to the BackRepo
func (*BackRepoContentStruct) CommitPhaseOne ¶
func (backRepoContent *BackRepoContentStruct) CommitPhaseOne(stage *models.StageStruct) (Error error)
BackRepoContent.CommitPhaseOne commits all staged instances of Content to the BackRepo Phase One is the creation of instance in the database if it is not yet done to get the unique ID for each staged instance
func (*BackRepoContentStruct) CommitPhaseOneInstance ¶
func (backRepoContent *BackRepoContentStruct) CommitPhaseOneInstance(content *models.Content) (Error error)
BackRepoContent.CommitPhaseOneInstance commits content staged instances of Content to the BackRepo Phase One is the creation of instance in the database if it is not yet done to get the unique ID for each staged instance
func (*BackRepoContentStruct) CommitPhaseTwo ¶
func (backRepoContent *BackRepoContentStruct) CommitPhaseTwo(backRepo *BackRepoStruct) (Error error)
BackRepoContent.CommitPhaseTwo commits all staged instances of Content to the BackRepo Phase Two is the update of instance with the field in the database
func (*BackRepoContentStruct) CommitPhaseTwoInstance ¶
func (backRepoContent *BackRepoContentStruct) CommitPhaseTwoInstance(backRepo *BackRepoStruct, idx uint, content *models.Content) (Error error)
BackRepoContent.CommitPhaseTwoInstance commits {{structname }} of models.Content to the BackRepo Phase Two is the update of instance with the field in the database
func (*BackRepoContentStruct) GetContentDBFromContentPtr ¶
func (backRepoContent *BackRepoContentStruct) GetContentDBFromContentPtr(content *models.Content) (contentDB *ContentDB)
GetContentDBFromContentPtr is a handy function to access the back repo instance from the stage instance
func (*BackRepoContentStruct) GetDB ¶
func (backRepoContent *BackRepoContentStruct) GetDB() db.DBInterface
func (*BackRepoContentStruct) GetStage ¶
func (backRepoContent *BackRepoContentStruct) GetStage() (stage *models.StageStruct)
func (*BackRepoContentStruct) ResetReversePointers ¶
func (backRepoContent *BackRepoContentStruct) ResetReversePointers(backRepo *BackRepoStruct) (Error error)
BackRepoContent.ResetReversePointers commits all staged instances of Content to the BackRepo Phase Two is the update of instance with the field in the database
func (*BackRepoContentStruct) ResetReversePointersInstance ¶
func (backRepoContent *BackRepoContentStruct) ResetReversePointersInstance(backRepo *BackRepoStruct, idx uint, content *models.Content) (Error error)
func (*BackRepoContentStruct) RestorePhaseOne ¶
func (backRepoContent *BackRepoContentStruct) RestorePhaseOne(dirPath string)
RestorePhaseOne read the file "ContentDB.json" in dirPath that stores an array of ContentDB and stores it in the database the map BackRepoContentid_atBckpTime_newID is updated accordingly
func (*BackRepoContentStruct) RestorePhaseTwo ¶
func (backRepoContent *BackRepoContentStruct) RestorePhaseTwo()
RestorePhaseTwo uses all map BackRepo<Content>id_atBckpTime_newID to compute new index
func (*BackRepoContentStruct) RestoreXLPhaseOne ¶
func (backRepoContent *BackRepoContentStruct) RestoreXLPhaseOne(file *xlsx.File)
RestoreXL from the "Content" sheet all ContentDB instances
type BackRepoData ¶
type BackRepoData struct {
ContentAPIs []*ContentAPI
}
type BackRepoStruct ¶
type BackRepoStruct struct { // insertion point for per struct back repo declarations BackRepoContent BackRepoContentStruct CommitFromBackNb uint // records commit increments when performed by the back PushFromFrontNb uint // records commit increments when performed by the front // contains filtered or unexported fields }
BackRepoStruct supports callback functions
func NewBackRepo ¶
func NewBackRepo(stage *models.StageStruct, filename string) (backRepo *BackRepoStruct)
func (*BackRepoStruct) Backup ¶
func (backRepo *BackRepoStruct) Backup(stage *models.StageStruct, dirPath string)
Backup the BackRepoStruct
func (*BackRepoStruct) BackupXL ¶
func (backRepo *BackRepoStruct) BackupXL(stage *models.StageStruct, dirPath string)
Backup in XL the BackRepoStruct
func (*BackRepoStruct) Checkout ¶
func (backRepo *BackRepoStruct) Checkout(stage *models.StageStruct)
Checkout the database into the stage
func (*BackRepoStruct) CheckoutContent ¶
func (backRepo *BackRepoStruct) CheckoutContent(content *models.Content)
CommitContent allows checkout of a single content (if already staged and with a BackRepo id)
func (*BackRepoStruct) Commit ¶
func (backRepo *BackRepoStruct) Commit(stage *models.StageStruct)
Commit the BackRepoStruct inner variables and link to the database
func (*BackRepoStruct) CommitContent ¶
func (backRepo *BackRepoStruct) CommitContent(content *models.Content)
CommitContent allows commit of a single content (if already staged)
func (*BackRepoStruct) GetLastCommitFromBackNb ¶
func (backRepo *BackRepoStruct) GetLastCommitFromBackNb() uint
func (*BackRepoStruct) GetLastPushFromFrontNb ¶
func (backRepo *BackRepoStruct) GetLastPushFromFrontNb() uint
func (*BackRepoStruct) GetStage ¶
func (backRepo *BackRepoStruct) GetStage() (stage *models.StageStruct)
func (*BackRepoStruct) IncrementCommitFromBackNb ¶
func (backRepo *BackRepoStruct) IncrementCommitFromBackNb() uint
func (*BackRepoStruct) IncrementPushFromFrontNb ¶
func (backRepo *BackRepoStruct) IncrementPushFromFrontNb() uint
func (*BackRepoStruct) Restore ¶
func (backRepo *BackRepoStruct) Restore(stage *models.StageStruct, dirPath string)
Restore the database into the back repo
func (*BackRepoStruct) RestoreXL ¶
func (backRepo *BackRepoStruct) RestoreXL(stage *models.StageStruct, dirPath string)
Restore the database into the back repo
func (*BackRepoStruct) SubscribeToCommitNb ¶
func (backRepoStruct *BackRepoStruct) SubscribeToCommitNb(ctx context.Context) <-chan int
type ContentAPI ¶
type ContentAPI struct { gorm.Model models.Content_WOP // encoding of pointers // for API, it cannot be embedded ContentPointersEncoding ContentPointersEncoding }
ContentAPI is the input in POST API
for POST, API, one needs the fields of the model as well as the fields from associations ("Has One" and "Has Many") that are generated to fullfill the ORM requirements for associations
swagger:model contentAPI
type ContentDB ¶
type ContentDB struct { gorm.Model // Declation for basic field contentDB.Name Name_Data sql.NullString // Declation for basic field contentDB.Content Content_Data sql.NullString // encoding of pointers // for GORM serialization, it is necessary to embed to Pointer Encoding declaration ContentPointersEncoding }
ContentDB describes a content in the database
It incorporates the GORM ID, basic fields from the model (because they can be serialized), the encoded version of pointers
swagger:model contentDB
func (*ContentDB) CopyBasicFieldsFromContent ¶
CopyBasicFieldsFromContent
func (*ContentDB) CopyBasicFieldsFromContentWOP ¶
func (contentDB *ContentDB) CopyBasicFieldsFromContentWOP(content *ContentWOP)
CopyBasicFieldsFromContentWOP
func (*ContentDB) CopyBasicFieldsFromContent_WOP ¶
func (contentDB *ContentDB) CopyBasicFieldsFromContent_WOP(content *models.Content_WOP)
CopyBasicFieldsFromContent_WOP
func (*ContentDB) CopyBasicFieldsToContent ¶
CopyBasicFieldsToContent
func (*ContentDB) CopyBasicFieldsToContentWOP ¶
func (contentDB *ContentDB) CopyBasicFieldsToContentWOP(content *ContentWOP)
CopyBasicFieldsToContentWOP
func (*ContentDB) CopyBasicFieldsToContent_WOP ¶
func (contentDB *ContentDB) CopyBasicFieldsToContent_WOP(content *models.Content_WOP)
CopyBasicFieldsToContent_WOP
func (*ContentDB) DecodePointers ¶
func (contentDB *ContentDB) DecodePointers(backRepo *BackRepoStruct, content *models.Content)
type ContentDBResponse ¶
type ContentDBResponse struct {
ContentDB
}
ContentDBResponse provides response swagger:response contentDBResponse
type ContentDBs ¶
type ContentDBs []ContentDB
ContentDBs arrays contentDBs swagger:response contentDBsResponse
type ContentPointersEncoding ¶
type ContentPointersEncoding struct { }
ContentPointersEncoding encodes pointers to Struct and reverse pointers of slice of poitners to Struct
type ContentWOP ¶
ContentWOP is a Content without pointers (WOP is an acronym for "Without Pointers") it holds the same basic fields but pointers are encoded into uint
type DBLite ¶
type DBLite struct {
// contains filtered or unexported fields
}
DBLite is an in-memory database implementation of DBInterface
func (*DBLite) Create ¶
func (db *DBLite) Create(instanceDB any) (db.DBInterface, error)
Create inserts a new record into the database
func (*DBLite) Delete ¶
func (db *DBLite) Delete(instanceDB any) (db.DBInterface, error)
Delete removes a record from the database
func (*DBLite) Find ¶
func (db *DBLite) Find(instanceDBs any) (db.DBInterface, error)
Find retrieves all records of a type from the database
func (*DBLite) Model ¶
func (db *DBLite) Model(instanceDB any) (db.DBInterface, error)
Model is a placeholder in this implementation
func (*DBLite) Save ¶
func (db *DBLite) Save(instanceDB any) (db.DBInterface, error)
Save updates or inserts a record into the database
type GongstructDB ¶
type GongstructDB interface { }