Documentation
¶
Overview ¶
Package erm stands for Entity-Relationship Modeling
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BelongsTo ¶
func BelongsTo[Who, ToWhom any, ToWhomID comparable](accessor extid.Accessor[Who, ToWhomID]) func()
BelongsTo is a HasMany relationship, where "Who" belongs to "ToWhom" through the "ToWhomID".
Example ¶
package main
import (
"go.llib.dev/frameless/port/crud/relationship"
)
func main() {
type AID string
type A struct {
ID AID
}
type BID string
type B struct {
ID BID
TheAID AID
}
// describe how the two Entity Type is in relationship
// BelongsTo[B, A] -> "B" belongs to "A" through the "B"."TheAID"
var _ = relationship.BelongsTo[B, A](func(b *B) *AID {
return &b.TheAID
})
}
func HasReference ¶
func ReferencesMany ¶
func ReferencesMany[A, B any, BID comparable](accessor extid.Accessor[A, []BID]) func()
ReferencesMany is a HasMany relationship, where A references many B by a slice of B IDs.
Example ¶
package main
import (
"go.llib.dev/frameless/port/crud/relationship"
)
func main() {
type AID string
type BID string
type A struct {
ID AID
BRefs []BID
}
type B struct {
ID BID
}
// describe how the two Entity Type is in relationship
// BelongsTo[B, A] -> "B" belongs to "A" through the "B"."TheAID"
var _ = relationship.ReferencesMany[A, B](func(a *A) *[]BID {
return &a.BRefs
})
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.