datastore

package
v0.0.3-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONSISTENCY_LOCAL int = iota
	CONSISTENCY_QUORUM
)
View Source
const (
	SORT_ASCENDING = iota
	SORT_DESCENDING
)
View Source
const (
	QUERY_TYPE_COUNT = iota
)

Variables

View Source
var (
	ErrInvalidSerializer = errors.New("serializer: invalid serializer type")
)
View Source
var (
	ErrRecordNotFound = errors.New("datastore: record not found")
)

Functions

func Deserialize

func Deserialize[E any](data []byte, serializer Serializer) (E, error)

Deserializes the provided data using the specified serializer

func Serialize

func Serialize(data interface{}, serializer Serializer) ([]byte, error)

Serializes the provided data using the specified serializer

func SerializerExtension

func SerializerExtension(serializer Serializer) string

Returns the file extension for the provided serializer

Types

type Factory

type Factory interface {
	OrganizationDAO() (OrganizationDAO, error)
	UserDAO() (UserDAO, error)
	RegistrationDAO() (RegistrationDAO, error)
	RoleDAO() (RoleDAO, error)
	WebAuthnDAO() (WebAuthnDAO, error)
}

type GenericDAO

type GenericDAO[E any] interface {
	Save(entity E) error
	Get(id uint64, CONSISTENCY_LEVEL int) (E, error)
	Delete(entity E) error
	Count(CONSISTENCY_LEVEL int) (int, error)
	Pager[E]
}

type OrganizationDAO

type OrganizationDAO interface {
	GetUsers(id uint64, CONSISTENCY_LEVEL int) ([]*entities.User, error)
	GenericDAO[*entities.Organization]
}

type PageQuery

type PageQuery struct {
	Page      int
	PageSize  int
	SortOrder int
}

PageQuery represents a datastore query for a single page of records

func NewPageQuery

func NewPageQuery() PageQuery

type PageResult

type PageResult[E any] struct {
	Entities []E  `yaml:"entities" json:"entities"`
	Page     int  `yaml:"page" json:"page"`
	PageSize int  `yaml:"size" json:"size"`
	HasMore  bool `yaml:"has_more" json:"has_more"`
}

PageResult represents a datastore page query resultset

func NewPageResult

func NewPageResult[E any]() PageResult[E]

func NewPageResultFromQuery

func NewPageResultFromQuery[E any](q PageQuery) PageResult[E]

type Pager

type Pager[E any] interface {
	Page(pageQuery PageQuery, CONSISTENCY_LEVEL int) (PageResult[E], error)
	ForEachPage(pageQuery PageQuery, pagerProcFunc PagerProcFunc[E], CONSISTENCY_LEVEL int) error
}

type PagerProcFunc

type PagerProcFunc[E any] func(entities []E) error

type RegistrationDAO

type RegistrationDAO interface {
	GenericDAO[*entities.Registration]
}

type RoleDAO

type RoleDAO interface {
	GetByName(name string, CONSISTENCY_LEVEL int) (*entities.Role, error)
	GenericDAO[*entities.Role]
}

type Serializer

type Serializer int
const (
	SERIALIZER_JSON Serializer = iota
	SERIALIZER_YAML
)

type UserDAO

type UserDAO interface {
	GenericDAO[*entities.User]
}

type WebAuthnDAO

type WebAuthnDAO interface {
	GenericDAO[*entities.Blob]
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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