utils

package
v0.0.0-...-5f05b73 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractAccessor

type AbstractAccessor struct {
	Logger zerolog.Logger    // Logger is the logger of the accessor, it's a specilized logger for the accessor
	Type   string            // Type is the data type of the accessor
	Caller *tools.HTTPCaller // Caller is the http caller of the accessor (optionnal) only need in a peer connection
}

func (*AbstractAccessor) GenericDeleteOne

func (dma *AbstractAccessor) GenericDeleteOne(id string, accessor Accessor) (DBObject, int, error)

GenericLoadOne loads one object from the database (generic)

func (*AbstractAccessor) GenericStoreOne

func (wfa *AbstractAccessor) GenericStoreOne(data DBObject, accessor Accessor) (DBObject, int, error)

GenericLoadOne loads one object from the database (generic)

func (*AbstractAccessor) GenericUpdateOne

func (dma *AbstractAccessor) GenericUpdateOne(set DBObject, id string, accessor Accessor, new DBObject) (DBObject, int, error)

GenericLoadOne loads one object from the database (generic) json expected in entry is a flatted object no need to respect the inheritance hierarchy

func (*AbstractAccessor) GetCaller

func (dma *AbstractAccessor) GetCaller() *tools.HTTPCaller

func (*AbstractAccessor) GetType

func (dma *AbstractAccessor) GetType() string

func (*AbstractAccessor) Init

func (dma *AbstractAccessor) Init(t tools.DataType, caller *tools.HTTPCaller)

Init initializes the accessor with the data type and the http caller

type AbstractObject

type AbstractObject struct {
	UUID           string    `json:"id,omitempty" bson:"id,omitempty" validate:"required"`
	Name           string    `json:"name,omitempty" bson:"name,omitempty" validate:"required"`
	UpdateDate     time.Time `json:"update_date" bson:"update_date"`
	LastPeerWriter string    `json:"last_peer_writer" bson:"last_peer_writer"`
}

* AbstractObject is a struct that represents the basic fields of an object * it defines the object id and name * every data in base root model should inherit from this struct (only exception is the ResourceModel)

func (*AbstractObject) Deserialize

func (dma *AbstractObject) Deserialize(j map[string]interface{}) DBObject

func (*AbstractObject) GenerateID

func (r *AbstractObject) GenerateID()

func (*AbstractObject) GetAccessor

func (dma *AbstractObject) GetAccessor(caller *tools.HTTPCaller) Accessor

GetAccessor returns the accessor of the object (abstract)

func (*AbstractObject) GetID

func (ao *AbstractObject) GetID() string

GetID returns the id of the object (abstract)

func (*AbstractObject) GetName

func (ao *AbstractObject) GetName() string

GetName returns the name of the object (abstract)

func (*AbstractObject) Serialize

func (dma *AbstractObject) Serialize() map[string]interface{}

func (*AbstractObject) UpToDate

func (ao *AbstractObject) UpToDate()

type Accessor

type Accessor interface {
	Init(t tools.DataType, caller *tools.HTTPCaller)
	GetType() string
	GetCaller() *tools.HTTPCaller
	Search(filters *dbs.Filters, search string) ([]ShallowDBObject, int, error)
	LoadAll() ([]ShallowDBObject, int, error)
	LoadOne(id string) (DBObject, int, error)
	DeleteOne(id string) (DBObject, int, error)
	CopyOne(data DBObject) (DBObject, int, error)
	StoreOne(data DBObject) (DBObject, int, error)
	UpdateOne(set DBObject, id string) (DBObject, int, error)
}

Accessor is an interface that defines the basic methods for an Accessor

type DBObject

type DBObject interface {
	GenerateID()
	GetID() string
	GetName() string
	UpToDate()
	Deserialize(j map[string]interface{}) DBObject
	Serialize() map[string]interface{}
	GetAccessor(caller *tools.HTTPCaller) Accessor
}

DBObject is an interface that defines the basic methods for a DBObject

type ShallowDBObject

type ShallowDBObject interface {
	GenerateID()
	GetID() string
	GetName() string
	Deserialize(j map[string]interface{}) DBObject
	Serialize() map[string]interface{}
}

ShallowDBObject is an interface that defines the basic methods shallowed version of a DBObject

Jump to

Keyboard shortcuts

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