Documentation
¶
Overview ¶
Package typestore runs the type store's steps over the statements any database engine lends it.
Index ¶
- func FieldsByGroup(declared []FieldRow) map[int][]content.Field
- func GroupFromRow(engine dbkit.Engine, row GroupRow) (content.Group, error)
- func Serves(g content.Group, typeKey string) bool
- type Backend
- type Constraint
- type FieldQueries
- type FieldRow
- type GroupQueries
- type GroupRow
- type Queries
- type Rule
- type Store
- func (s *Store) AdoptGroup(ctx context.Context, key string) error
- func (s *Store) AdoptType(ctx context.Context, key string) error
- func (s *Store) ByKey(ctx context.Context, key string) (content.Type, error)
- func (s *Store) Create(ctx context.Context, t content.Type) (content.Type, error)
- func (s *Store) CreateFieldInGroup(ctx context.Context, groupID int, f content.Field, recheck content.Recheck) (content.Field, error)
- func (s *Store) CreateGroup(ctx context.Context, g content.Group) (content.Group, error)
- func (s *Store) CreateSubField(ctx context.Context, parentID int, f content.Field, limit int) (content.Field, error)
- func (s *Store) Delete(ctx context.Context, key string) error
- func (s *Store) DeleteFieldInGroup(ctx context.Context, groupID int, key string, recheck content.Recheck) error
- func (s *Store) DeleteFieldsOfGroup(ctx context.Context, groupID int, keys []string, recheck content.Recheck) error
- func (s *Store) DeleteGroup(ctx context.Context, id int, recheck content.Recheck) error
- func (s *Store) DeleteSubField(ctx context.Context, id int, recheck content.Recheck) error
- func (s *Store) List(ctx context.Context) ([]content.Type, error)
- func (s *Store) ListGroups(ctx context.Context) ([]content.Group, error)
- func (s *Store) MoveField(ctx context.Context, id, toGroup, toParent, limit int, recheck content.Recheck) (content.Field, error)
- func (s *Store) Nested(ctx context.Context, key string) (int, error)
- func (s *Store) ReorderFieldsInGroup(ctx context.Context, groupID int, keys []string) error
- func (s *Store) ReorderGroups(ctx context.Context, ids []int) error
- func (s *Store) ReorderSubFields(ctx context.Context, parentID int, keys []string) error
- func (s *Store) Update(ctx context.Context, t content.Type) (content.Type, error)
- func (s *Store) UpdateFieldInGroup(ctx context.Context, groupID int, f content.Field, expectedUpdatedAt time.Time, ...) (content.Field, error)
- func (s *Store) UpdateGroup(ctx context.Context, g content.Group, repointed []content.Field, ...) (content.Group, error)
- func (s *Store) UpdateSubField(ctx context.Context, id int, f content.Field, expectedUpdatedAt time.Time) (content.Field, error)
- type Strip
- type Transactor
- type TypeQueries
- type TypeRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FieldsByGroup ¶
FieldsByGroup returns the stored field rows as trees, keyed by the group holding them.
func GroupFromRow ¶
GroupFromRow returns the group a stored row holds, naming the engine when its location does not read.
Types ¶
type Backend ¶
type Backend struct {
Engine dbkit.Engine
Pool Queries
InTx Transactor
Rules []Rule
ReadError func(err error) (code, name string, found bool)
}
Backend holds what one database engine lends the type store.
type Constraint ¶
type Constraint int
Constraint names a stored rule a statement broke, whatever the engine calls that rule.
const ( NoConstraint Constraint = iota GroupKeyUnique FieldKeyUnique FieldTargetExists FieldGroupExists TypeKeyUnique RouteWordUnique TypeHeldByContent ContentPathUnique )
The stored rules the steps tell apart.
type FieldQueries ¶
type FieldQueries interface {
ListContentFields(ctx context.Context) ([]FieldRow, error)
FieldByID(ctx context.Context, id int) (FieldRow, error)
CreateContentField(ctx context.Context, f FieldRow) (FieldRow, error)
CreateSubContentField(ctx context.Context, f FieldRow) (FieldRow, error)
UpdateContentField(ctx context.Context, f FieldRow, expected time.Time) (FieldRow, error)
UpdateSubContentField(ctx context.Context, f FieldRow, expected time.Time) (FieldRow, error)
ReorderContentFields(ctx context.Context, groupID int, keys []string) (int64, error)
ReorderSubContentFields(ctx context.Context, parentID int, keys []string) (int64, error)
ReparentContentField(ctx context.Context, id, toGroup, toParent int, at time.Time) (FieldRow, error)
RecountContentFieldDepth(ctx context.Context, id, toGroup, depth int) error
DeleteContentField(ctx context.Context, groupID int, key string) (int64, error)
DeleteFieldByID(ctx context.Context, id int) (int64, error)
ClearContentFieldValues(ctx context.Context, key string, types []string) error
ClearRevisionFieldValues(ctx context.Context, key string, types []string) error
StripContentFieldPath(ctx context.Context, s Strip) error
StripRevisionFieldPath(ctx context.Context, s Strip) error
StripContentLayout(ctx context.Context, s Strip) error
StripRevisionLayout(ctx context.Context, s Strip) error
DeleteRelationsOfFields(ctx context.Context, types []string, fields []int) error
}
FieldQueries sends the statements that read, write and sweep field definitions.
type FieldRow ¶
type FieldRow struct {
ID, GroupID, ParentID, Depth int
Key, Label, Kind, RelatesTo, Origin string
Many, Required bool
Settings []byte
CreatedAt, UpdatedAt time.Time
}
FieldRow is one stored field definition with its depth, its settings still encoded as JSON.
type GroupQueries ¶
type GroupQueries interface {
LockFieldGroups(ctx context.Context) error
ListFieldGroups(ctx context.Context) ([]GroupRow, error)
FieldGroupKeys(ctx context.Context) ([]string, error)
CreateFieldGroup(ctx context.Context, g GroupRow) (GroupRow, error)
UpdateFieldGroup(ctx context.Context, g GroupRow) (GroupRow, error)
ReorderFieldGroups(ctx context.Context, ids []int) error
CarryStrayFieldsOfGroup(ctx context.Context, groupID int) error
DeleteFieldGroup(ctx context.Context, id int) (int64, error)
AdoptFieldGroup(ctx context.Context, key string, at time.Time) (int64, error)
AdoptFieldsInGroup(ctx context.Context, key string, at time.Time) error
}
GroupQueries sends the statements that read and write field groups.
type GroupRow ¶
type GroupRow struct {
ID, Position int
Key, Title, Origin string
Location []byte
Active bool
CreatedAt, UpdatedAt time.Time
}
GroupRow is one stored field group, its location still encoded as JSON.
type Queries ¶
type Queries interface {
TypeQueries
GroupQueries
FieldQueries
}
Queries sends every statement the type store is built from, one call per statement.
type Rule ¶
type Rule struct {
Code, Name string
Broken Constraint
}
Rule names the stored rule an engine's error code and rule name stand for, an empty one matching any.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps the content type registry and its field groups through one backend.
func (*Store) AdoptGroup ¶
AdoptGroup clears the plugin origin from the group and every field inside it, or reports the site holding none.
func (*Store) AdoptType ¶
AdoptType clears the plugin origin from the type, or reports the site holding none under the key.
func (*Store) ByKey ¶
ByKey returns the type carrying the key with its flattened fields, or content.ErrTypeNotFound.
func (*Store) Create ¶
Create stores a new content type, or reports the key or route word already in use.
func (*Store) CreateFieldInGroup ¶
func (s *Store) CreateFieldInGroup( ctx context.Context, groupID int, f content.Field, recheck content.Recheck, ) (content.Field, error)
CreateFieldInGroup declares the field inside the group.
func (*Store) CreateGroup ¶
CreateGroup stores a new field group at the end of the order.
func (*Store) CreateSubField ¶
func (s *Store) CreateSubField( ctx context.Context, parentID int, f content.Field, limit int, ) (content.Field, error)
CreateSubField declares the field inside the container the parent names, within the limit.
func (*Store) DeleteFieldInGroup ¶
func (s *Store) DeleteFieldInGroup(ctx context.Context, groupID int, key string, recheck content.Recheck) error
DeleteFieldInGroup removes the field, sweeping its values as a group delete does.
func (*Store) DeleteFieldsOfGroup ¶
func (s *Store) DeleteFieldsOfGroup( ctx context.Context, groupID int, keys []string, recheck content.Recheck, ) error
DeleteFieldsOfGroup removes the group's named top level fields, sweeping their values as a group delete does.
func (*Store) DeleteGroup ¶
DeleteGroup removes the group, its fields and their stored values in one transaction, once the check passes.
func (*Store) DeleteSubField ¶
DeleteSubField removes the sub field, and its values where no other active group serves its path.
func (*Store) List ¶
List returns every registered type in registration order with its flattened fields attached.
func (*Store) ListGroups ¶
ListGroups returns every field group in position order with its fields attached.
func (*Store) MoveField ¶
func (s *Store) MoveField( ctx context.Context, id, toGroup, toParent, limit int, recheck content.Recheck, ) (content.Field, error)
MoveField carries the field to a group's top or into a container within the limit, sweeping what it leaves.
func (*Store) Nested ¶
Nested returns how many items of the type sit inside another, the ones in the trash included.
func (*Store) ReorderFieldsInGroup ¶
ReorderFieldsInGroup stores the declaration order of a group's fields.
func (*Store) ReorderGroups ¶
ReorderGroups stores the given order on the groups.
func (*Store) ReorderSubFields ¶
ReorderSubFields stands the sub fields of the container in the order the keys name.
func (*Store) Update ¶
Update stores the type's edits and carries its content to the route word, or reports content.ErrTypeNotFound.
func (*Store) UpdateFieldInGroup ¶
func (s *Store) UpdateFieldInGroup( ctx context.Context, groupID int, f content.Field, expectedUpdatedAt time.Time, recheck content.Recheck, ) (content.Field, error)
UpdateFieldInGroup stores the field's label, required flag and settings when the expectation and the check hold.
type Transactor ¶
Transactor runs write on statements bound to one transaction, committing when write returns nil.
type TypeQueries ¶
type TypeQueries interface {
ListContentTypes(ctx context.Context) ([]TypeRow, error)
GetContentType(ctx context.Context, key string) (TypeRow, error)
CreateContentType(ctx context.Context, t TypeRow) (TypeRow, error)
LockContentType(ctx context.Context, key string) (TypeRow, error)
LockDefaultContentType(ctx context.Context) (TypeRow, error)
UpdateContentType(ctx context.Context, t TypeRow) (TypeRow, error)
DeferAddressCheck(ctx context.Context) error
RetypeContentPaths(ctx context.Context, t TypeRow, was string) error
CountNestedContent(ctx context.Context, key string) (int64, error)
DeleteContentType(ctx context.Context, key string) (int64, error)
AdoptContentType(ctx context.Context, key string, at time.Time) (int64, error)
TypeKeys(ctx context.Context) ([]string, error)
}
TypeQueries sends the statements that read and write content types.