A continuation of HomeBox the inventory and organization system built for the Home User
package repo
import (
"github.com/google/uuid"
"github.com/samber/lo"
"github.com/sysadminsmedia/homebox/backend/pkgs/set"
)
// HasID is an interface to entities that have an ID uuid.UUID field and a GetID() method.
// This interface is fulfilled by all entities generated by entgo.io/ent via a custom template
type HasID interface {
GetID() uuid.UUID
}
func newIDSet[T HasID](entities []T) set.Set[uuid.UUID] {
uuids := lo.Map(entities, func(e T, _ int) uuid.UUID {
return e.GetID()
})
return set.New(uuids...)
}