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 ¶
- func FindReferenceField(collection schema.Collection, fieldID schema.StableID) (reference schema.Field, root schema.Field, found bool)
- func NullifyField(field schema.Field, value store.Value, target store.DocumentReference, ...) (store.Value, bool)
- func NullifyTarget(collection schema.Collection, values store.Values, ...) (store.Values, bool)
- func ReferenceFieldIDs(root schema.Field) []schema.StableID
- func RemoveResourceTargets(collection schema.Collection, values store.Values, ...) (store.Values, bool)
- func TargetsAnyResource(collection schema.Collection, resourceIDs []schema.StableID) bool
- type Entry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
func NullifyField ¶
func NullifyField(field schema.Field, value store.Value, target store.DocumentReference, locale schema.LocaleCode) (store.Value, bool)
NullifyField reconciles a target beneath one stored root field. locale is non-empty only when value came from one localized physical column.
func NullifyTarget ¶
func NullifyTarget(collection schema.Collection, values store.Values, target store.DocumentReference) (store.Values, bool)
NullifyTarget reconciles every nullify-policy reference in a current document. Callers must plan restrict matches across the whole transaction before invoking it.
func ReferenceFieldIDs ¶
ReferenceFieldIDs returns every relationship/upload field ID beneath one stored root field.
func RemoveResourceTargets ¶
func RemoveResourceTargets(collection schema.Collection, values store.Values, resourceIDs []schema.StableID) (store.Values, bool)
RemoveResourceTargets removes every current relationship or upload value that addresses a retired resource, regardless of the field's ordinary document-delete policy. A schema rollback removes the target type itself, so retaining restrict-policy values would only leave dormant identities that could reappear on a later up migration.
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.
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
Collect derives every relationship and upload reference in one canonical current document, including nested containers and localized values.
func CollectField ¶
func CollectField(owner store.DocumentReference, field schema.Field, value store.Value, locale schema.LocaleCode) []Entry
CollectField derives references beneath one stored root field. For a localized physical column, locale identifies the column and value is the unwrapped locale value. An empty locale means value has canonical storage shape and may itself contain locale maps.