crud

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// ListEntities lists all entity types in backend (such as tables)
	ListEntities() ([]string, error)
	// ListItems lists items based on provided query
	ListItems(entity string, qry query.Interface) (*PagedResult, error)
	// Exists checks for existence of item based on ID
	Exists(entity, id string) (bool, error)
	// Get gets item based on ID
	Get(entity, id string) (Untyped, error)
	// Update item by its ID
	Update(entity, id string, body Untyped) (Untyped, error)
	// Create creates new item
	Create(entity string, body Untyped) (Untyped, error)
	// Delete deletes item by its ID
	Delete(entity string, id string) error
}

Interface is API to perform CRUD operation against backend

func New

func New(be *types.BackendConfig, n string, logger *slog.Logger) Interface

type NameToCrudMap

type NameToCrudMap map[string]Interface

func (*NameToCrudMap) Close

func (m *NameToCrudMap) Close() error

type PagedResult added in v1.0.1

type PagedResult struct {
	Data       []Untyped `json:"data"`
	TotalCount int       `json:"total_count"`
	Offset     uint64    `json:"offset"`
}

type Untyped

type Untyped map[string]interface{}

Jump to

Keyboard shortcuts

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