defaultstore

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package defaultstore implements the SQL-backed default store for the organizations plugin.

Dialect selection happens once in NewDefaultOrganizationStore; all methods are dialect-agnostic and delegate to the unexported querier interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultOrganizationStore

type DefaultOrganizationStore struct {
	// contains filtered or unexported fields
}

DefaultOrganizationStore implements orgtypes.OrganizationStore using a SQL database.

All dialect logic is confined to the querier: this struct holds only the single chosen querier and delegates every operation to it.

func NewDefaultOrganizationStore

func NewDefaultOrganizationStore(db *sql.DB, dialect plugins.Dialect) (*DefaultOrganizationStore, error)

NewDefaultOrganizationStore creates a DefaultOrganizationStore for the given dialect.

func (*DefaultOrganizationStore) CanAccessTeam added in v1.7.0

func (s *DefaultOrganizationStore) CanAccessTeam(ctx context.Context, userID, teamID string) (bool, error)

CanAccessTeam checks whether a user can access a team.

Access requires being a member of the parent organization AND a member of the team, with any role in each — custom roles are not second-class here.

func (*DefaultOrganizationStore) CountInvitations added in v1.7.0

func (s *DefaultOrganizationStore) CountInvitations(ctx context.Context, orgID string, teamID string) (int, error)

CountInvitations returns the total number of invitations matching filters.

func (*DefaultOrganizationStore) CountOrganizationMembers

func (s *DefaultOrganizationStore) CountOrganizationMembers(ctx context.Context, orgID string) (int, error)

CountOrganizationMembers returns the total number of members in an organization.

func (*DefaultOrganizationStore) CountTeamMembers

func (s *DefaultOrganizationStore) CountTeamMembers(ctx context.Context, teamID string) (int, error)

CountTeamMembers returns the total number of members in a team.

func (*DefaultOrganizationStore) CountTeams

func (s *DefaultOrganizationStore) CountTeams(ctx context.Context, orgID string) (int, error)

CountTeams returns the total number of teams within an organization.

func (*DefaultOrganizationStore) CountUserOrganizations

func (s *DefaultOrganizationStore) CountUserOrganizations(ctx context.Context, userID string) (int, error)

CountUserOrganizations returns the total number of organizations the user belongs to.

func (*DefaultOrganizationStore) CreateInvitation added in v1.7.0

func (s *DefaultOrganizationStore) CreateInvitation(ctx context.Context, inv orgtypes.Invitation) error

CreateInvitation stores a new invitation.

func (*DefaultOrganizationStore) CreateMember

func (s *DefaultOrganizationStore) CreateMember(ctx context.Context, id, userID, orgID, role string, createdAt, updatedAt time.Time) error

CreateMember adds a user as a member of an organization with the given role.

func (*DefaultOrganizationStore) CreateOrganization

func (s *DefaultOrganizationStore) CreateOrganization(ctx context.Context, id, name, slug string, createdAt, updatedAt time.Time) error

CreateOrganization creates a new organization with the given attributes.

func (*DefaultOrganizationStore) CreateTeam

func (s *DefaultOrganizationStore) CreateTeam(ctx context.Context, id, orgID, name, description string, createdAt, updatedAt time.Time) error

CreateTeam creates a new team within an organization.

func (*DefaultOrganizationStore) CreateTeamMember

func (s *DefaultOrganizationStore) CreateTeamMember(ctx context.Context, id, teamID, userID, role string, createdAt, updatedAt time.Time) error

CreateTeamMember adds a user as a member of a team with the given role.

func (*DefaultOrganizationStore) DeleteInvitation added in v1.7.0

func (s *DefaultOrganizationStore) DeleteInvitation(ctx context.Context, id string) error

DeleteInvitation deletes an invitation by ID.

func (*DefaultOrganizationStore) DeleteOrganization

func (s *DefaultOrganizationStore) DeleteOrganization(ctx context.Context, id string, updatedAt time.Time) error

DeleteOrganization soft-deletes an organization by ID.

func (*DefaultOrganizationStore) DeleteTeam

func (s *DefaultOrganizationStore) DeleteTeam(ctx context.Context, id string) error

DeleteTeam removes a team by its ID.

func (*DefaultOrganizationStore) GetInvitationByID added in v1.7.0

func (s *DefaultOrganizationStore) GetInvitationByID(ctx context.Context, id string) (orgtypes.Invitation, error)

GetInvitationByID retrieves an invitation by ID.

func (*DefaultOrganizationStore) GetInvitationByTokenHash added in v1.7.0

func (s *DefaultOrganizationStore) GetInvitationByTokenHash(ctx context.Context, tokenHash string) (orgtypes.Invitation, error)

GetInvitationByTokenHash retrieves an invitation by token hash.

func (*DefaultOrganizationStore) GetMember

func (s *DefaultOrganizationStore) GetMember(ctx context.Context, userID, orgID string) (orgtypes.Member, error)

GetMember retrieves the membership record for a user in an organization.

func (*DefaultOrganizationStore) GetOrganization

func (s *DefaultOrganizationStore) GetOrganization(ctx context.Context, id string) (orgtypes.Organization, error)

GetOrganization retrieves an organization by its ID.

func (*DefaultOrganizationStore) GetOrganizationBySlug

func (s *DefaultOrganizationStore) GetOrganizationBySlug(ctx context.Context, slug string) (orgtypes.Organization, error)

GetOrganizationBySlug retrieves an organization by its URL slug.

func (*DefaultOrganizationStore) GetTeam

GetTeam retrieves a team by its ID.

func (*DefaultOrganizationStore) GetTeamMember

func (s *DefaultOrganizationStore) GetTeamMember(ctx context.Context, teamID, userID string) (orgtypes.TeamMember, error)

GetTeamMember retrieves the membership record for a user in a team.

func (*DefaultOrganizationStore) HasOrgRole added in v1.7.0

func (s *DefaultOrganizationStore) HasOrgRole(ctx context.Context, userID, orgID string, roles ...string) (bool, error)

HasOrgRole checks whether the user has any of the given org-level roles.

func (*DefaultOrganizationStore) HasTeamRole added in v1.7.0

func (s *DefaultOrganizationStore) HasTeamRole(ctx context.Context, userID, teamID string, roles ...string) (bool, error)

HasTeamRole checks whether the user has any of the given team-level roles.

func (*DefaultOrganizationStore) IsOrganizationMember deprecated

func (s *DefaultOrganizationStore) IsOrganizationMember(ctx context.Context, userID, orgID string) (bool, error)

IsOrganizationMember reports whether the user is a member of the organization.

Deprecated: Use HasOrgRole instead. Returns true for any role.

func (*DefaultOrganizationStore) IsOwner

func (s *DefaultOrganizationStore) IsOwner(ctx context.Context, userID, orgID string) (bool, error)

IsOwner reports whether the user is the owner of the organization.

func (*DefaultOrganizationStore) IsOwnerOrAdmin deprecated

func (s *DefaultOrganizationStore) IsOwnerOrAdmin(ctx context.Context, userID, orgID string) (bool, error)

IsOwnerOrAdmin reports whether the user has the owner or admin role in the organization.

Deprecated: Use HasOrgRole instead.

func (*DefaultOrganizationStore) ListInvitations added in v1.7.0

func (s *DefaultOrganizationStore) ListInvitations(ctx context.Context, orgID string, teamID string, offset, limit int) ([]orgtypes.Invitation, error)

ListInvitations returns a paginated list of invitations for an org.

func (*DefaultOrganizationStore) ListOrganizationMembers

func (s *DefaultOrganizationStore) ListOrganizationMembers(ctx context.Context, orgID string, offset, limit int) ([]orgtypes.Member, error)

ListOrganizationMembers returns a paginated list of members in an organization.

func (*DefaultOrganizationStore) ListTeamMembers

func (s *DefaultOrganizationStore) ListTeamMembers(ctx context.Context, teamID string, offset, limit int) ([]orgtypes.TeamMember, error)

ListTeamMembers returns a paginated list of members in a team.

func (*DefaultOrganizationStore) ListTeams

func (s *DefaultOrganizationStore) ListTeams(ctx context.Context, orgID string, offset, limit int) ([]orgtypes.Team, error)

ListTeams returns a paginated list of teams within an organization.

func (*DefaultOrganizationStore) ListUserOrganizations

func (s *DefaultOrganizationStore) ListUserOrganizations(ctx context.Context, userID string, offset, limit int) ([]orgtypes.Organization, error)

ListUserOrganizations returns a paginated list of organizations the user belongs to.

func (*DefaultOrganizationStore) RemoveMember

func (s *DefaultOrganizationStore) RemoveMember(ctx context.Context, userID, orgID string) error

RemoveMember removes a user from an organization.

func (*DefaultOrganizationStore) RemoveTeamMember

func (s *DefaultOrganizationStore) RemoveTeamMember(ctx context.Context, teamID, userID string) error

RemoveTeamMember removes a user from a team.

func (*DefaultOrganizationStore) UpdateInvitationStatus added in v1.7.0

func (s *DefaultOrganizationStore) UpdateInvitationStatus(ctx context.Context, id, status string, updatedAt time.Time) error

UpdateInvitationStatus updates the status of an invitation.

func (*DefaultOrganizationStore) UpdateMemberRole

func (s *DefaultOrganizationStore) UpdateMemberRole(ctx context.Context, userID, orgID, role string, updatedAt time.Time) error

UpdateMemberRole updates the role of a member within an organization.

func (*DefaultOrganizationStore) UpdateOrganization

func (s *DefaultOrganizationStore) UpdateOrganization(ctx context.Context, id, name, slug string, updatedAt time.Time) error

UpdateOrganization updates the name, slug, and updatedAt timestamp for an organization.

func (*DefaultOrganizationStore) UpdateTeam

func (s *DefaultOrganizationStore) UpdateTeam(ctx context.Context, id, name, description string, updatedAt time.Time) error

UpdateTeam updates the name, description, and updatedAt timestamp for a team.

func (*DefaultOrganizationStore) UpdateTeamMemberRole

func (s *DefaultOrganizationStore) UpdateTeamMemberRole(ctx context.Context, teamID, userID, role string, updatedAt time.Time) error

UpdateTeamMemberRole updates the role of a member within a team.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL