orm

package
v0.0.0-...-6a59abf Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

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

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

Index

Constants

This section is empty.

Variables

View Source
var A_Fields = []string{

	"ID",
	"Name",
	"NumberField",
}
View Source
var B_Fields = []string{

	"ID",
	"Name",
}
View Source
var BackRepoAid_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 BackRepoBid_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

Functions

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 AAPI

type AAPI struct {
	gorm.Model

	models.A_WOP

	// encoding of pointers
	APointersEncoding APointersEncoding
}

AAPI 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 aAPI

type ADB

type ADB struct {
	gorm.Model

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

	// Declation for basic field aDB.NumberField
	NumberField_Data sql.NullInt64
	// encoding of pointers
	APointersEncoding
}

ADB describes a a 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 aDB

func (*ADB) CopyBasicFieldsFromA

func (aDB *ADB) CopyBasicFieldsFromA(a *models.A)

CopyBasicFieldsFromA

func (*ADB) CopyBasicFieldsFromAWOP

func (aDB *ADB) CopyBasicFieldsFromAWOP(a *AWOP)

CopyBasicFieldsFromAWOP

func (*ADB) CopyBasicFieldsFromA_WOP

func (aDB *ADB) CopyBasicFieldsFromA_WOP(a *models.A_WOP)

CopyBasicFieldsFromA_WOP

func (*ADB) CopyBasicFieldsToA

func (aDB *ADB) CopyBasicFieldsToA(a *models.A)

CopyBasicFieldsToA

func (*ADB) CopyBasicFieldsToAWOP

func (aDB *ADB) CopyBasicFieldsToAWOP(a *AWOP)

CopyBasicFieldsToAWOP

func (*ADB) CopyBasicFieldsToA_WOP

func (aDB *ADB) CopyBasicFieldsToA_WOP(a *models.A_WOP)

CopyBasicFieldsToA_WOP

func (*ADB) DecodePointers

func (aDB *ADB) DecodePointers(backRepo *BackRepoStruct, a *models.A)

type ADBResponse

type ADBResponse struct {
	ADB
}

ADBResponse provides response swagger:response aDBResponse

type ADBs

type ADBs []ADB

ADBs arrays aDBs swagger:response aDBsResponse

type APointersEncoding

type APointersEncoding struct {

	// field B is a pointer to another Struct (optional or 0..1)
	// This field is generated into another field to enable AS ONE association
	BID sql.NullInt64

	// field Bs is a slice of pointers to another Struct (optional or 0..1)
	Bs IntSlice `gorm:"type:TEXT"`
}

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

type AWOP

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

	Name string `xlsx:"1"`

	NumberField int `xlsx:"2"`
}

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

type BAPI

type BAPI struct {
	gorm.Model

	models.B_WOP

	// encoding of pointers
	BPointersEncoding BPointersEncoding
}

BAPI 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 bAPI

type BDB

type BDB struct {
	gorm.Model

	// Declation for basic field bDB.Name
	Name_Data sql.NullString
	// encoding of pointers
	BPointersEncoding
}

BDB describes a b 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 bDB

func (*BDB) CopyBasicFieldsFromB

func (bDB *BDB) CopyBasicFieldsFromB(b *models.B)

CopyBasicFieldsFromB

func (*BDB) CopyBasicFieldsFromBWOP

func (bDB *BDB) CopyBasicFieldsFromBWOP(b *BWOP)

CopyBasicFieldsFromBWOP

func (*BDB) CopyBasicFieldsFromB_WOP

func (bDB *BDB) CopyBasicFieldsFromB_WOP(b *models.B_WOP)

CopyBasicFieldsFromB_WOP

func (*BDB) CopyBasicFieldsToB

func (bDB *BDB) CopyBasicFieldsToB(b *models.B)

CopyBasicFieldsToB

func (*BDB) CopyBasicFieldsToBWOP

func (bDB *BDB) CopyBasicFieldsToBWOP(b *BWOP)

CopyBasicFieldsToBWOP

func (*BDB) CopyBasicFieldsToB_WOP

func (bDB *BDB) CopyBasicFieldsToB_WOP(b *models.B_WOP)

CopyBasicFieldsToB_WOP

func (*BDB) DecodePointers

func (bDB *BDB) DecodePointers(backRepo *BackRepoStruct, b *models.B)

type BDBResponse

type BDBResponse struct {
	BDB
}

BDBResponse provides response swagger:response bDBResponse

type BDBs

type BDBs []BDB

BDBs arrays bDBs swagger:response bDBsResponse

type BPointersEncoding

type BPointersEncoding struct {
}

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

type BWOP

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

	Name string `xlsx:"1"`
}

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

type BackRepoAStruct

type BackRepoAStruct struct {
	// stores ADB according to their gorm ID
	Map_ADBID_ADB map[uint]*ADB

	// stores ADB ID according to A address
	Map_APtr_ADBID map[*models.A]uint

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

func (*BackRepoAStruct) Backup

func (backRepoA *BackRepoAStruct) Backup(dirPath string)

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

func (*BackRepoAStruct) BackupXL

func (backRepoA *BackRepoAStruct) BackupXL(file *xlsx.File)

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

func (*BackRepoAStruct) CheckoutPhaseOne

func (backRepoA *BackRepoAStruct) CheckoutPhaseOne() (Error error)

BackRepoA.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 (*BackRepoAStruct) CheckoutPhaseOneInstance

func (backRepoA *BackRepoAStruct) CheckoutPhaseOneInstance(aDB *ADB) (Error error)

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

func (*BackRepoAStruct) CheckoutPhaseTwo

func (backRepoA *BackRepoAStruct) CheckoutPhaseTwo(backRepo *BackRepoStruct) (Error error)

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

func (*BackRepoAStruct) CheckoutPhaseTwoInstance

func (backRepoA *BackRepoAStruct) CheckoutPhaseTwoInstance(backRepo *BackRepoStruct, aDB *ADB) (Error error)

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

func (*BackRepoAStruct) CommitDeleteInstance

func (backRepoA *BackRepoAStruct) CommitDeleteInstance(id uint) (Error error)

BackRepoA.CommitDeleteInstance commits deletion of A to the BackRepo

func (*BackRepoAStruct) CommitPhaseOne

func (backRepoA *BackRepoAStruct) CommitPhaseOne(stage *models.StageStruct) (Error error)

BackRepoA.CommitPhaseOne commits all staged instances of A 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 (*BackRepoAStruct) CommitPhaseOneInstance

func (backRepoA *BackRepoAStruct) CommitPhaseOneInstance(a *models.A) (Error error)

BackRepoA.CommitPhaseOneInstance commits a staged instances of A 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 (*BackRepoAStruct) CommitPhaseTwo

func (backRepoA *BackRepoAStruct) CommitPhaseTwo(backRepo *BackRepoStruct) (Error error)

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

func (*BackRepoAStruct) CommitPhaseTwoInstance

func (backRepoA *BackRepoAStruct) CommitPhaseTwoInstance(backRepo *BackRepoStruct, idx uint, a *models.A) (Error error)

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

func (*BackRepoAStruct) GetADBFromAPtr

func (backRepoA *BackRepoAStruct) GetADBFromAPtr(a *models.A) (aDB *ADB)

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

func (*BackRepoAStruct) GetDB

func (backRepoA *BackRepoAStruct) GetDB() *gorm.DB

func (*BackRepoAStruct) GetStage

func (backRepoA *BackRepoAStruct) GetStage() (stage *models.StageStruct)

func (*BackRepoAStruct) ResetReversePointers

func (backRepoA *BackRepoAStruct) ResetReversePointers(backRepo *BackRepoStruct) (Error error)

BackRepoA.ResetReversePointers commits all staged instances of A to the BackRepo Phase Two is the update of instance with the field in the database

func (*BackRepoAStruct) ResetReversePointersInstance

func (backRepoA *BackRepoAStruct) ResetReversePointersInstance(backRepo *BackRepoStruct, idx uint, a *models.A) (Error error)

func (*BackRepoAStruct) RestorePhaseOne

func (backRepoA *BackRepoAStruct) RestorePhaseOne(dirPath string)

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

func (*BackRepoAStruct) RestorePhaseTwo

func (backRepoA *BackRepoAStruct) RestorePhaseTwo()

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

func (*BackRepoAStruct) RestoreXLPhaseOne

func (backRepoA *BackRepoAStruct) RestoreXLPhaseOne(file *xlsx.File)

RestoreXL from the "A" sheet all ADB instances

type BackRepoBStruct

type BackRepoBStruct struct {
	// stores BDB according to their gorm ID
	Map_BDBID_BDB map[uint]*BDB

	// stores BDB ID according to B address
	Map_BPtr_BDBID map[*models.B]uint

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

func (*BackRepoBStruct) Backup

func (backRepoB *BackRepoBStruct) Backup(dirPath string)

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

func (*BackRepoBStruct) BackupXL

func (backRepoB *BackRepoBStruct) BackupXL(file *xlsx.File)

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

func (*BackRepoBStruct) CheckoutPhaseOne

func (backRepoB *BackRepoBStruct) CheckoutPhaseOne() (Error error)

BackRepoB.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 (*BackRepoBStruct) CheckoutPhaseOneInstance

func (backRepoB *BackRepoBStruct) CheckoutPhaseOneInstance(bDB *BDB) (Error error)

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

func (*BackRepoBStruct) CheckoutPhaseTwo

func (backRepoB *BackRepoBStruct) CheckoutPhaseTwo(backRepo *BackRepoStruct) (Error error)

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

func (*BackRepoBStruct) CheckoutPhaseTwoInstance

func (backRepoB *BackRepoBStruct) CheckoutPhaseTwoInstance(backRepo *BackRepoStruct, bDB *BDB) (Error error)

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

func (*BackRepoBStruct) CommitDeleteInstance

func (backRepoB *BackRepoBStruct) CommitDeleteInstance(id uint) (Error error)

BackRepoB.CommitDeleteInstance commits deletion of B to the BackRepo

func (*BackRepoBStruct) CommitPhaseOne

func (backRepoB *BackRepoBStruct) CommitPhaseOne(stage *models.StageStruct) (Error error)

BackRepoB.CommitPhaseOne commits all staged instances of B 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 (*BackRepoBStruct) CommitPhaseOneInstance

func (backRepoB *BackRepoBStruct) CommitPhaseOneInstance(b *models.B) (Error error)

BackRepoB.CommitPhaseOneInstance commits b staged instances of B 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 (*BackRepoBStruct) CommitPhaseTwo

func (backRepoB *BackRepoBStruct) CommitPhaseTwo(backRepo *BackRepoStruct) (Error error)

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

func (*BackRepoBStruct) CommitPhaseTwoInstance

func (backRepoB *BackRepoBStruct) CommitPhaseTwoInstance(backRepo *BackRepoStruct, idx uint, b *models.B) (Error error)

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

func (*BackRepoBStruct) GetBDBFromBPtr

func (backRepoB *BackRepoBStruct) GetBDBFromBPtr(b *models.B) (bDB *BDB)

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

func (*BackRepoBStruct) GetDB

func (backRepoB *BackRepoBStruct) GetDB() *gorm.DB

func (*BackRepoBStruct) GetStage

func (backRepoB *BackRepoBStruct) GetStage() (stage *models.StageStruct)

func (*BackRepoBStruct) ResetReversePointers

func (backRepoB *BackRepoBStruct) ResetReversePointers(backRepo *BackRepoStruct) (Error error)

BackRepoB.ResetReversePointers commits all staged instances of B to the BackRepo Phase Two is the update of instance with the field in the database

func (*BackRepoBStruct) ResetReversePointersInstance

func (backRepoB *BackRepoBStruct) ResetReversePointersInstance(backRepo *BackRepoStruct, idx uint, b *models.B) (Error error)

func (*BackRepoBStruct) RestorePhaseOne

func (backRepoB *BackRepoBStruct) RestorePhaseOne(dirPath string)

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

func (*BackRepoBStruct) RestorePhaseTwo

func (backRepoB *BackRepoBStruct) RestorePhaseTwo()

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

func (*BackRepoBStruct) RestoreXLPhaseOne

func (backRepoB *BackRepoBStruct) RestoreXLPhaseOne(file *xlsx.File)

RestoreXL from the "B" sheet all BDB instances

type BackRepoStruct

type BackRepoStruct struct {
	// insertion point for per struct back repo declarations
	BackRepoA BackRepoAStruct

	BackRepoB BackRepoBStruct

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

func (backRepo *BackRepoStruct) CheckoutA(a *models.A)

CommitA allows checkout of a single a (if already staged and with a BackRepo id)

func (*BackRepoStruct) CheckoutB

func (backRepo *BackRepoStruct) CheckoutB(b *models.B)

CommitB allows checkout of a single b (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) CommitA

func (backRepo *BackRepoStruct) CommitA(a *models.A)

CommitA allows commit of a single a (if already staged)

func (*BackRepoStruct) CommitB

func (backRepo *BackRepoStruct) CommitB(b *models.B)

CommitB allows commit of a single b (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 GongstructDB

type GongstructDB interface {
	// insertion point for generic types
	// "int" is present to handle the case when no struct is present
	int | ADB | BDB
}

type IntSlice

type IntSlice []int

func (*IntSlice) Scan

func (s *IntSlice) Scan(value interface{}) error

Scan makes IntSlice implement the sql.Scanner interface.

func (IntSlice) Value

func (s IntSlice) Value() (driver.Value, error)

Value makes IntSlice implement the driver.Valuer interface.

Jump to

Keyboard shortcuts

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