Documentation ¶
Overview ¶
Package repository provides the APIs for making 'resource' related database interactions.
Index ¶
- type GormResourceRepository
- func (m *GormResourceRepository) CheckExists(ctx context.Context, id string) error
- func (m *GormResourceRepository) Create(ctx context.Context, resource *Resource) error
- func (m *GormResourceRepository) Delete(ctx context.Context, id string) error
- func (m *GormResourceRepository) FindWithRoleByResourceTypeAndIdentity(ctx context.Context, resourceType string, identityID uuid.UUID) ([]string, error)
- func (m *GormResourceRepository) Load(ctx context.Context, id string) (*Resource, error)
- func (m *GormResourceRepository) LoadChildren(ctx context.Context, id string) ([]Resource, error)
- func (m *GormResourceRepository) Save(ctx context.Context, resource *Resource) error
- func (m *GormResourceRepository) TableName() string
- type Resource
- type ResourceRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GormResourceRepository ¶
type GormResourceRepository struct {
// contains filtered or unexported fields
}
GormResourceRepository is the implementation of the storage interface for Resource.
func (*GormResourceRepository) CheckExists ¶
func (m *GormResourceRepository) CheckExists(ctx context.Context, id string) error
CheckExists returns nil if the given ID exists otherwise returns an error
func (*GormResourceRepository) Create ¶
func (m *GormResourceRepository) Create(ctx context.Context, resource *Resource) error
Create creates a new record.
func (*GormResourceRepository) Delete ¶
func (m *GormResourceRepository) Delete(ctx context.Context, id string) error
Delete removes a single record.
func (*GormResourceRepository) FindWithRoleByResourceTypeAndIdentity ¶
func (m *GormResourceRepository) FindWithRoleByResourceTypeAndIdentity(ctx context.Context, resourceType string, identityID uuid.UUID) ([]string, error)
FindWithRoleByResourceTypeAndIdentity returns the IDs of the resources of the given type for which the given user (identity) has a role in.
func (*GormResourceRepository) LoadChildren ¶
LoadChildren returns direct children resources of the given resource or an empty array if no children found
func (*GormResourceRepository) Save ¶
func (m *GormResourceRepository) Save(ctx context.Context, resource *Resource) error
Save modifies a single record.
func (*GormResourceRepository) TableName ¶
func (m *GormResourceRepository) TableName() string
TableName overrides the table name settings in Gorm to force a specific table name in the database.
type Resource ¶
type Resource struct { gormsupport.Lifecycle // This is the primary key value ResourceID string `sql:"type:string" gorm:"primary_key;column:resource_id"` // The parent resource ID ParentResourceID *string // The parent resource ParentResource *Resource `gorm:"foreignkey:ParentResourceID;association_foreignkey:ResourceID"` // The resource type ResourceType resourcetype.ResourceType `gorm:"foreignkey:ResourceTypeID;association_foreignkey:ResourceTypeID"` // The identifier for the resource type ResourceTypeID uuid.UUID // Resource name Name string }
func (Resource) GetLastModified ¶
GetLastModified returns the last modification time
type ResourceRepository ¶
type ResourceRepository interface { base.Exister Load(ctx context.Context, id string) (*Resource, error) LoadChildren(ctx context.Context, id string) ([]Resource, error) Create(ctx context.Context, resource *Resource) error Save(ctx context.Context, resource *Resource) error Delete(ctx context.Context, id string) error FindWithRoleByResourceTypeAndIdentity(ctx context.Context, resourceType string, identityID uuid.UUID) ([]string, error) }
ResourceRepository represents the storage interface.
func NewResourceRepository ¶
func NewResourceRepository(db *gorm.DB) ResourceRepository
NewResourceRepository creates a new storage type.