Help us shape the future of Go! Take the 2026 Go Developer Survey

referenceindex

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package referenceindex derives and reconciles current relationship and upload references from canonical store values. It is shared by official stores so the strict test adapter and PostgreSQL cannot silently diverge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlocksDelete added in v0.9.0

func BlocksDelete(action schema.ReferenceDeleteAction, owner store.DocumentReference, pending map[store.DocumentReference]bool) (bool, error)

BlocksDelete reports whether a current reference prevents a hard delete of its target. Restrict always does. Cascade does too unless the owner's own delete is pending: the engine deletes cascade owners before the target, so a remaining one appeared concurrently and must not be silently cleared.

func CascadeOwners added in v0.9.0

func CascadeOwners(entries []Entry, collections map[schema.StableID]schema.Collection, pending map[store.DocumentReference]bool) ([]store.DocumentReference, error)

CascadeOwners returns the distinct owners, in a stable order, whose entries reference their target through a cascade field. Callers pass entries that already exclude ignored owners; entries from pending owners are skipped.

func DeleteAction added in v0.9.0

func DeleteAction(field schema.Field) schema.ReferenceDeleteAction

DeleteAction returns the hard-delete policy of a relationship or upload field.

func FindReferenceField

func FindReferenceField(collection schema.Collection, fieldID schema.StableID) (reference schema.Field, root schema.Field, found bool)

FindReferenceField locates a relationship/upload field and its stored root field by stable ID. A registered block's field is returned with its placement path and ID. Placement IDs extend their ancestors' IDs, so the search follows only the path that can lead to fieldID.

func MayReference added in v0.25.0

func MayReference(collection schema.Collection) bool

MayReference reports whether the collection's documents can hold a relationship or upload value at any depth, including block and plugin payloads, and so own reference index entries. Collect finds none in a collection for which it is false. Each block definition is inspected once.

func NullifyField

func NullifyField(field schema.Field, value store.Value, target store.DocumentReference, locale schema.LocaleCode) (store.Value, bool, error)

func NullifyTarget

func NullifyTarget(collection schema.Collection, values store.Values, target store.DocumentReference) (store.Values, bool, error)

func PendingSet added in v0.9.0

func PendingSet(owners []store.DocumentReference) map[store.DocumentReference]bool

PendingSet indexes the owners whose hard delete is already in progress.

func ReferenceFieldIDs

func ReferenceFieldIDs(resource schema.StableID, root schema.Field) []schema.StableID

ReferenceFieldIDs returns every relationship/upload field placement ID beneath one stored root field of resource, skipping field lists without references.

func RemoveResourceTargets

func RemoveResourceTargets(collection schema.Collection, values store.Values, resources []schema.StableID) (store.Values, bool, error)

func TargetsAnyResource

func TargetsAnyResource(collection schema.Collection, resourceIDs []schema.StableID) bool

TargetsAnyResource reports whether the collection's current reference or upload topology can address one of the supplied resource IDs. Migration rollback uses this to purge version snapshots that could otherwise restore an identity after its resource is reintroduced. Each block definition is inspected once.

Types

type Entry

type Entry struct {
	Owner      store.DocumentReference
	FieldID    schema.StableID
	Target     store.DocumentReference
	Locale     schema.LocaleCode
	Occurrence int
}

Entry is one current reference occurrence owned by a document. Occurrence is deterministic within the owner/field/target/locale tuple and permits duplicate list members without collapsing the derived index.

func Collect

func Collect(collection schema.Collection, document store.Document) ([]Entry, error)

Collect validates the complete declared envelope before deriving any index entries. A malformed or over-budget tree must never yield a partial index.

func CollectField

func CollectField(owner store.DocumentReference, field schema.Field, value store.Value, locale schema.LocaleCode) ([]Entry, error)

Jump to

Keyboard shortcuts

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