revisions

package
v0.0.0-...-1fccfa7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Created     = "created"
	Updated     = "updated"
	SoftDeleted = "soft-deleted"
	Undeleted   = "undeleted"
	HardDeleted = "hard-deleted"
)
View Source
const (
	RevisionResourceType = "corteza::system:revision"
)

Variables

This section is empty.

Functions

func Model

func Model() *dal.Model

Model returns generic dal.Model for storing revisions

Returns only basic

func Service

func Service(dal creatorSearcher) *service

Types

type Change

type Change struct {
	// changed field
	Key string `json:"key"`

	Old []any `json:"old,omitempty"`
	New []any `json:"new,omitempty"`
}

type Filter

type Filter struct {
	ResourceID uint64 `json:"resourceID,string"`
}

func (Filter) Constraints

func (f Filter) Constraints() map[string][]any

func (Filter) Cursor

func (f Filter) Cursor() *filter.PagingCursor

func (Filter) Expression

func (f Filter) Expression() string

func (Filter) Limit

func (f Filter) Limit() uint

func (Filter) OrderBy

func (f Filter) OrderBy() filter.SortExprSet

func (Filter) StateConstraints

func (f Filter) StateConstraints() map[string]filter.State

type Operation

type Operation = string

type Revision

type Revision struct {
	ID        uint64    `json:"changeID,string"`
	Timestamp time.Time `json:"timestamp"`

	ResourceID uint64 `json:"resourceID,string"`

	Revision  int       `json:"revision"`
	Operation Operation `json:"operation"`

	UserID uint64 `json:"userID,string"`

	Changes []*Change `json:"changes"`

	Comment string `json:"comment"`
}

generic revision struct

func Make

func Make(op Operation, revision int, resourceID, userID uint64) (rev *Revision)

func (*Revision) CollectChanges

func (r *Revision) CollectChanges(new, old dal.ValueGetter, skip ...string) (err error)

untested

func (*Revision) CountValues

func (r *Revision) CountValues() map[string]uint

CountValues satisfies dal.ValueGetter interface

func (*Revision) GetValue

func (r *Revision) GetValue(ident string, _ uint) (any, error)

GetValue satisfies dal.ValueGetter interface

func (*Revision) SetValue

func (r *Revision) SetValue(name string, _ uint, value any) error

type Servicer

type Servicer interface {
	Search(ctx context.Context, mf dal.ModelRef, f filter.Filter) (_ dal.Iterator, err error)
	Create(ctx context.Context, mf dal.ModelRef, revision *Revision) error
}

Jump to

Keyboard shortcuts

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