Documentation ¶
Index ¶
- func WithTx(ctx context.Context, tx *sql.Tx) context.Context
- type AdminRepository
- type ConfigurationRepository
- type MenuRepository
- type Metas
- type NodeRepository
- func (r *NodeRepository) Create(ctx context.Context, m *model.Node) error
- func (r *NodeRepository) Delete(ctx context.Context, ids ...int64) error
- func (r *NodeRepository) FindWithChildren(ctx context.Context, id int64) ([]model.Node, error)
- func (r *NodeRepository) Update(ctx context.Context, m *model.Node) error
- type PageRepository
- func (r *PageRepository) Create(ctx context.Context, m *model.Page) error
- func (r *PageRepository) FindByAlias(ctx context.Context, siteID int64, alias string, now time.Time) (model.Page, error)
- func (r *PageRepository) FindByParentID(ctx context.Context, parentID int64, now time.Time) ([]model.Page, error)
- func (r *PageRepository) FindByPattern(ctx context.Context, siteID int64, pattern string, now time.Time) (model.Page, error)
- func (r *PageRepository) FindByURL(ctx context.Context, siteID int64, url string, now time.Time) (model.Page, error)
- func (r *PageRepository) Update(ctx context.Context, m *model.Page) error
- type Repository
- func (r Repository[T, ID]) Create(ctx context.Context, m *T) error
- func (r Repository[T, ID]) Delete(ctx context.Context, ids ...ID) error
- func (r Repository[T, ID]) Find(ctx context.Context, criteria *cr.Criteria) ([]T, error)
- func (r Repository[T, ID]) FindAndCount(ctx context.Context, criteria *cr.Criteria) ([]T, int, error)
- func (r Repository[T, ID]) FindBy(ctx context.Context, column string, value any) (m T, err error)
- func (r Repository[T, ID]) FindByID(ctx context.Context, id ID) (T, error)
- func (r Repository[T, ID]) Update(ctx context.Context, m *T) error
- type Roles
- type SessionRepository
- func (p *SessionRepository) All() (map[string][]byte, error)
- func (p *SessionRepository) Commit(token string, b []byte, expiry time.Time) error
- func (p *SessionRepository) Delete(token string) error
- func (p *SessionRepository) Find(token string) (b []byte, exists bool, err error)
- func (p *SessionRepository) StopCleanup()
- type SiteRepository
- type StrMap
- type TemplateRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdminRepository ¶
type AdminRepository struct { Repository[model.Admin, int64] }
func NewAdminRepository ¶
func NewAdminRepository(db *sql.DB) *AdminRepository
func (*AdminRepository) FindByEmail ¶
type ConfigurationRepository ¶
type ConfigurationRepository struct {
// contains filtered or unexported fields
}
func NewConfigurationRepository ¶
func NewConfigurationRepository(db *sql.DB) *ConfigurationRepository
func (*ConfigurationRepository) Load ¶
func (r *ConfigurationRepository) Load(ctx context.Context) (model.Configuration, error)
func (*ConfigurationRepository) Save ¶
func (r *ConfigurationRepository) Save(ctx context.Context, m *model.Configuration) error
type MenuRepository ¶
type MenuRepository struct { Repository[model.Menu, int64] }
func NewMenuRepository ¶
func NewMenuRepository(db *sql.DB) *MenuRepository
func (*MenuRepository) FindByHandle ¶
type NodeRepository ¶
type NodeRepository struct { Repository[model.Node, int64] // contains filtered or unexported fields }
func NewNodeRepository ¶
func NewNodeRepository(db *sql.DB) *NodeRepository
func (*NodeRepository) Delete ¶
func (r *NodeRepository) Delete(ctx context.Context, ids ...int64) error
func (*NodeRepository) FindWithChildren ¶
type PageRepository ¶
type PageRepository struct { Repository[model.Page, int64] }
func NewPageRepository ¶
func NewPageRepository(db *sql.DB) *PageRepository
func (*PageRepository) FindByAlias ¶
func (*PageRepository) FindByParentID ¶
func (*PageRepository) FindByPattern ¶
type Repository ¶
type Repository[T interface{ GetID() ID }, ID any] struct { DB *sql.DB Table string SelectColumns []string RowScan func(interface{ Scan(dest ...any) error }, *T) error InsertValues func(*T) map[string]any UpdateValues func(*T) map[string]any OnError func(error) error }
func (Repository[T, ID]) Create ¶
func (r Repository[T, ID]) Create(ctx context.Context, m *T) error
func (Repository[T, ID]) Delete ¶
func (r Repository[T, ID]) Delete(ctx context.Context, ids ...ID) error
func (Repository[T, ID]) FindAndCount ¶
type SessionRepository ¶ added in v0.0.9
type SessionRepository struct {
// contains filtered or unexported fields
}
func NewSessionRepository ¶ added in v0.0.9
func NewSessionRepository(db *sql.DB, cleanupInterval time.Duration) *SessionRepository
NewSessionRepository returns a new PostgresStore instance. The cleanupInterval parameter controls how frequently expired session data is removed by the background cleanup goroutine. Setting it to 0 prevents the cleanup goroutine from running (i.e. expired sessions will not be removed).
func (*SessionRepository) All ¶ added in v0.0.9
func (p *SessionRepository) All() (map[string][]byte, error)
All returns a map containing the token and data for all active (i.e. not expired) sessions in the PostgresStore instance.
func (*SessionRepository) Commit ¶ added in v0.0.9
Commit adds a session token and data to the PostgresStore instance with the given expiry time. If the session token already exists, then the data and expiry time are updated.
func (*SessionRepository) Delete ¶ added in v0.0.9
func (p *SessionRepository) Delete(token string) error
Delete removes a session token and corresponding data from the PostgresStore instance.
func (*SessionRepository) Find ¶ added in v0.0.9
func (p *SessionRepository) Find(token string) (b []byte, exists bool, err error)
Find returns the data for a given session token from the PostgresStore instance. If the session token is not found or is expired, the returned exists flag will be set to false.
func (*SessionRepository) StopCleanup ¶ added in v0.0.9
func (p *SessionRepository) StopCleanup()
StopCleanup terminates the background cleanup goroutine for the PostgresStore instance. It's rare to terminate this; generally PostgresStore instances and their cleanup goroutines are intended to be long-lived and run for the lifetime of your application.
There may be occasions though when your use of the PostgresStore is transient. An example is creating a new PostgresStore instance in a test function. In this scenario, the cleanup goroutine (which will run forever) will prevent the PostgresStore object from being garbage collected even after the test function has finished. You can prevent this by manually calling StopCleanup.
type SiteRepository ¶
type SiteRepository struct { Repository[model.Site, int64] }
func NewSiteRepository ¶
func NewSiteRepository(db *sql.DB) *SiteRepository
type TemplateRepository ¶
type TemplateRepository struct { Repository[model.Template, int64] }
func NewTemplateRepository ¶
func NewTemplateRepository(db *sql.DB) *TemplateRepository