orm

package
v0.0.0-...-44acadb Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 20 Imported by: 0

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

Constants

This section is empty.

Variables

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

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

func (contentDB *ContentDB) CopyBasicFieldsFromContent(content *models.Content)

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

func (contentDB *ContentDB) CopyBasicFieldsToContent(content *models.Content)

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

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

	Name string `xlsx:"1"`

	Content string `xlsx:"2"`
}

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 NewDBLite

func NewDBLite() *DBLite

NewDBLite creates a new instance of DBLite

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

func (db *DBLite) First(instanceDB any, conds ...any) (db.DBInterface, error)

First retrieves the first record 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

func (*DBLite) Unscoped

func (db *DBLite) Unscoped() (db.DBInterface, error)

Unscoped sets the unscoped flag for soft-deletes (not used in this implementation)

func (*DBLite) Updates

func (db *DBLite) Updates(instanceDB any) (db.DBInterface, error)

Updates modifies an existing record in the database

type GongstructDB

type GongstructDB interface {
}

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.

Directories

Path Synopsis
generated code - do not edit
generated code - do not edit

Jump to

Keyboard shortcuts

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