orm

package
v0.0.0-...-64c3952 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

generated by stacks/gong/go/models/orm_file_per_struct_back_repo.go

Index

Constants

This section is empty.

Variables

View Source
var BackRepoOutletid_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

View Source
var Outlet_Fields = []string{

	"ID",
	"Name",
	"Path",
}

Functions

func GetLastCommitFromBackNb

func GetLastCommitFromBackNb() uint

func GetLastPushFromFrontNb

func GetLastPushFromFrontNb() uint

Types

type BackRepoOutletStruct

type BackRepoOutletStruct struct {
	// stores OutletDB according to their gorm ID
	Map_OutletDBID_OutletDB map[uint]*OutletDB

	// stores OutletDB ID according to Outlet address
	Map_OutletPtr_OutletDBID map[*models.Outlet]uint

	// stores Outlet according to their gorm ID
	Map_OutletDBID_OutletPtr map[uint]*models.Outlet
	// contains filtered or unexported fields
}

func (*BackRepoOutletStruct) Backup

func (backRepoOutlet *BackRepoOutletStruct) Backup(dirPath string)

Backup generates a json file from a slice of all OutletDB instances in the backrepo

func (*BackRepoOutletStruct) BackupXL

func (backRepoOutlet *BackRepoOutletStruct) BackupXL(file *xlsx.File)

Backup generates a json file from a slice of all OutletDB instances in the backrepo

func (*BackRepoOutletStruct) CheckoutPhaseOne

func (backRepoOutlet *BackRepoOutletStruct) CheckoutPhaseOne() (Error error)

BackRepoOutlet.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 (*BackRepoOutletStruct) CheckoutPhaseOneInstance

func (backRepoOutlet *BackRepoOutletStruct) CheckoutPhaseOneInstance(outletDB *OutletDB) (Error error)

CheckoutPhaseOneInstance takes a outletDB that has been found in the DB, updates the backRepo and stages the models version of the outletDB

func (*BackRepoOutletStruct) CheckoutPhaseTwo

func (backRepoOutlet *BackRepoOutletStruct) CheckoutPhaseTwo(backRepo *BackRepoStruct) (Error error)

BackRepoOutlet.CheckoutPhaseTwo Checkouts all staged instances of Outlet to the BackRepo Phase Two is the update of instance with the field in the database

func (*BackRepoOutletStruct) CheckoutPhaseTwoInstance

func (backRepoOutlet *BackRepoOutletStruct) CheckoutPhaseTwoInstance(backRepo *BackRepoStruct, outletDB *OutletDB) (Error error)

BackRepoOutlet.CheckoutPhaseTwoInstance Checkouts staged instances of Outlet to the BackRepo Phase Two is the update of instance with the field in the database

func (*BackRepoOutletStruct) CommitDeleteInstance

func (backRepoOutlet *BackRepoOutletStruct) CommitDeleteInstance(id uint) (Error error)

BackRepoOutlet.CommitDeleteInstance commits deletion of Outlet to the BackRepo

func (*BackRepoOutletStruct) CommitPhaseOne

func (backRepoOutlet *BackRepoOutletStruct) CommitPhaseOne(stage *models.StageStruct) (Error error)

BackRepoOutlet.CommitPhaseOne commits all staged instances of Outlet 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 (*BackRepoOutletStruct) CommitPhaseOneInstance

func (backRepoOutlet *BackRepoOutletStruct) CommitPhaseOneInstance(outlet *models.Outlet) (Error error)

BackRepoOutlet.CommitPhaseOneInstance commits outlet staged instances of Outlet 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 (*BackRepoOutletStruct) CommitPhaseTwo

func (backRepoOutlet *BackRepoOutletStruct) CommitPhaseTwo(backRepo *BackRepoStruct) (Error error)

BackRepoOutlet.CommitPhaseTwo commits all staged instances of Outlet to the BackRepo Phase Two is the update of instance with the field in the database

func (*BackRepoOutletStruct) CommitPhaseTwoInstance

func (backRepoOutlet *BackRepoOutletStruct) CommitPhaseTwoInstance(backRepo *BackRepoStruct, idx uint, outlet *models.Outlet) (Error error)

BackRepoOutlet.CommitPhaseTwoInstance commits {{structname }} of models.Outlet to the BackRepo Phase Two is the update of instance with the field in the database

func (*BackRepoOutletStruct) GetDB

func (backRepoOutlet *BackRepoOutletStruct) GetDB() *gorm.DB

func (*BackRepoOutletStruct) GetOutletDBFromOutletPtr

func (backRepoOutlet *BackRepoOutletStruct) GetOutletDBFromOutletPtr(outlet *models.Outlet) (outletDB *OutletDB)

GetOutletDBFromOutletPtr is a handy function to access the back repo instance from the stage instance

func (*BackRepoOutletStruct) GetStage

func (backRepoOutlet *BackRepoOutletStruct) GetStage() (stage *models.StageStruct)

func (*BackRepoOutletStruct) RestorePhaseOne

func (backRepoOutlet *BackRepoOutletStruct) RestorePhaseOne(dirPath string)

RestorePhaseOne read the file "OutletDB.json" in dirPath that stores an array of OutletDB and stores it in the database the map BackRepoOutletid_atBckpTime_newID is updated accordingly

func (*BackRepoOutletStruct) RestorePhaseTwo

func (backRepoOutlet *BackRepoOutletStruct) RestorePhaseTwo()

RestorePhaseTwo uses all map BackRepo<Outlet>id_atBckpTime_newID to compute new index

func (*BackRepoOutletStruct) RestoreXLPhaseOne

func (backRepoOutlet *BackRepoOutletStruct) RestoreXLPhaseOne(file *xlsx.File)

RestoreXL from the "Outlet" sheet all OutletDB instances

type BackRepoStruct

type BackRepoStruct struct {
	// insertion point for per struct back repo declarations
	BackRepoOutlet BackRepoOutletStruct

	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 GetDefaultBackRepo

func GetDefaultBackRepo() *BackRepoStruct

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) CheckoutOutlet

func (backRepo *BackRepoStruct) CheckoutOutlet(outlet *models.Outlet)

CommitOutlet allows checkout of a single outlet (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) CommitOutlet

func (backRepo *BackRepoStruct) CommitOutlet(outlet *models.Outlet)

CommitOutlet allows commit of a single outlet (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

type OutletAPI

type OutletAPI struct {
	gorm.Model

	models.Outlet

	// encoding of pointers
	OutletPointersEnconding
}

OutletAPI 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 outletAPI

type OutletDB

type OutletDB struct {
	gorm.Model

	// Declation for basic field outletDB.Name
	Name_Data sql.NullString

	// Declation for basic field outletDB.Path
	Path_Data sql.NullString
	// encoding of pointers
	OutletPointersEnconding
}

OutletDB describes a outlet 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 outletDB

func (*OutletDB) CopyBasicFieldsFromOutlet

func (outletDB *OutletDB) CopyBasicFieldsFromOutlet(outlet *models.Outlet)

CopyBasicFieldsFromOutlet

func (*OutletDB) CopyBasicFieldsFromOutletWOP

func (outletDB *OutletDB) CopyBasicFieldsFromOutletWOP(outlet *OutletWOP)

CopyBasicFieldsFromOutletWOP

func (*OutletDB) CopyBasicFieldsToOutlet

func (outletDB *OutletDB) CopyBasicFieldsToOutlet(outlet *models.Outlet)

CopyBasicFieldsToOutlet

func (*OutletDB) CopyBasicFieldsToOutletWOP

func (outletDB *OutletDB) CopyBasicFieldsToOutletWOP(outlet *OutletWOP)

CopyBasicFieldsToOutletWOP

type OutletDBResponse

type OutletDBResponse struct {
	OutletDB
}

OutletDBResponse provides response swagger:response outletDBResponse

type OutletDBs

type OutletDBs []OutletDB

OutletDBs arrays outletDBs swagger:response outletDBsResponse

type OutletPointersEnconding

type OutletPointersEnconding struct {
}

OutletPointersEnconding encodes pointers to Struct and reverse pointers of slice of poitners to Struct

type OutletWOP

type OutletWOP struct {
	ID int `xlsx:"0"`

	Name string `xlsx:"1"`

	Path string `xlsx:"2"`
}

OutletWOP is a Outlet without pointers (WOP is an acronym for "Without Pointers") it holds the same basic fields but pointers are encoded into uint

Jump to

Keyboard shortcuts

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