Documentation
¶
Overview ¶
Package morphmap holds the process-wide registry of polymorphic aliases shared by the orm and gorm packages. It mirrors fedaco's static Relation._morphMap (libs/fedaco/src/fedaco/ relations/relation.ts:31) while remaining safe for concurrent reads from many query goroutines.
Most app code interacts with the registry via the wrappers in package orm (orm.MorphMap, orm.MorphedModel, orm.MorphAlias). The lower-level gorm wrapper imports this package directly to resolve morph values during query construction without introducing a circular dependency on package orm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Find ¶
Find returns a fresh pointer to a new instance of the model registered under alias, or nil if no model is registered.
func MorphValue ¶
MorphValue resolves the morph alias for a model. Resolution order:
- model.MorphClass() if the model (or its pointer) implements ModelWithMorphClass
- global morph map (registered via Register)
Returns "" and false if neither resolves. The caller is then expected to fall back to GORM's `polymorphicValue:` tag or the parent's table name.
Types ¶
This section is empty.