repositories

package
v6.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound = errors.New("user not found")
)

Functions

This section is empty.

Types

type BlockRepository

type BlockRepository interface {
	// Create creates a new block for an owner with specific context
	Create(
		ctx context.Context,
		block blocks.Block,
		ownerID string,
		blockContext blocks.BlockContext,
	) (blocks.Block, error)

	// GetByID fetches a block by its ID
	GetByID(ctx context.Context, blockID string) (blocks.Block, error)
	// GetBlockAndStateByBlockIDAndTeamCode fetches a block and its state by block ID and team code
	GetBlockAndStateByBlockIDAndTeamCode(
		ctx context.Context,
		blockID string,
		teamCode string,
	) (blocks.Block, blocks.PlayerState, error)
	// UserOwnsBlock checks if a user owns a block
	UserOwnsBlock(ctx context.Context, userID, blockID string) (bool, error)
	// FindByOwnerID fetches all blocks for an owner (context agnostic)
	FindByOwnerID(ctx context.Context, ownerID string) (blocks.Blocks, error)
	// FindByOwnerIDAndContext fetches all blocks for an owner with specific context
	FindByOwnerIDAndContext(
		ctx context.Context,
		ownerID string,
		blockContext blocks.BlockContext,
	) (blocks.Blocks, error)
	// FindBlocksAndStatesByOwnerIDAndTeamCode fetches blocks and their states by owner and team code
	FindBlocksAndStatesByOwnerIDAndTeamCode(
		ctx context.Context,
		ownerID string,
		teamCode string,
	) ([]blocks.Block, []blocks.PlayerState, error)
	// FindBlocksAndStatesByOwnerIDAndTeamCodeWithContext fetches blocks and their states by owner, team code, and context
	FindBlocksAndStatesByOwnerIDAndTeamCodeWithContext(
		ctx context.Context,
		ownerID string,
		teamCode string,
		blockContext blocks.BlockContext,
	) ([]blocks.Block, []blocks.PlayerState, error)

	// Update updates an existing block
	Update(ctx context.Context, block blocks.Block) (blocks.Block, error)

	// Delete deletes a block by its ID
	// Requires a transaction as related data will also need to be deleted
	Delete(ctx context.Context, tx *bun.Tx, blockID string) error
	// DeleteByOwnerID deletes all blocks associated with an owner ID
	// Requires a transaction as related data will also need to be deleted
	DeleteByOwnerID(ctx context.Context, tx *bun.Tx, ownerID string) error

	// Reorder reorders the blocks for a specific location
	Reorder(ctx context.Context, blockIDs []string) error

	// DuplicateBlocksByOwner duplicates all blocks from oldOwnerID to newOwnerID
	// Preserves all block properties including context, ordering, points, etc.
	DuplicateBlocksByOwner(ctx context.Context, oldOwnerID, newOwnerID string) error
	// DuplicateBlocksByOwnerTx duplicates all blocks within a transaction
	DuplicateBlocksByOwnerTx(ctx context.Context, tx *bun.Tx, oldOwnerID, newOwnerID string) error

	// BulkCreate inserts multiple blocks for an owner with specific context
	// Blocks should have Order set explicitly; IDs will be generated
	BulkCreate(ctx context.Context, blockList []blocks.Block, ownerID string, blockContext blocks.BlockContext) error
}

func NewBlockRepository

func NewBlockRepository(db *bun.DB, stateRepo BlockStateRepository) BlockRepository

type BlockStateRepository

type BlockStateRepository interface {
	// Create creates a new player state
	Create(ctx context.Context, state blocks.PlayerState) (blocks.PlayerState, error)
	// NewBlockState creates a new block state for a specified block and team
	NewBlockState(ctx context.Context, blockID, teamCode string) (blocks.PlayerState, error)

	// GetByBlockAndTeam gets a player state by block ID and team code
	GetByBlockAndTeam(ctx context.Context, blockID string, teamCode string) (blocks.PlayerState, error)

	// Update updates an existing player state
	Update(ctx context.Context, block blocks.PlayerState) (blocks.PlayerState, error)

	// Delete deletes a player state by block ID and team code
	Delete(ctx context.Context, blockID string, teamCode string) error
	// DeleteByBlockID deletes all player states for a block
	// Requires a transaction as this implies a cascade delete
	DeleteByBlockID(ctx context.Context, tx *bun.Tx, blockID string) error
	// DeleteByTeamCodes deletes all player states for a team
	DeleteByTeamCodes(ctx context.Context, tx *bun.Tx, teamCodes []string) error
}

func NewBlockStateRepository

func NewBlockStateRepository(db *bun.DB) BlockStateRepository

type CheckInRepository

type CheckInRepository interface {
	// FindCheckInByTeamAndLocation finds a check-in by team and location
	FindCheckInByTeamAndLocation(ctx context.Context, teamCode string, locationID string) (*models.CheckIn, error)

	// LogCheckIn logs a new check-in for a team at a location
	LogCheckIn(
		ctx context.Context,
		team models.Team,
		location models.Location,
		mustCheckOut bool,
		validationRequired bool,
	) (models.CheckIn, error)
	// LogCheckOut checks out a team from a location
	LogCheckOut(ctx context.Context, team *models.Team, location *models.Location) (models.CheckIn, error)

	// Update updates an existing check-in
	Update(ctx context.Context, checkIn *models.CheckIn) error

	// DeleteByTeamCodes deletes all check-ins for the given teams
	DeleteByTeamCodes(ctx context.Context, tx *bun.Tx, instanceID string, teamCodes []string) error
}

func NewCheckInRepository

func NewCheckInRepository(db *bun.DB) CheckInRepository

type CreditPurchaseRepository

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

func NewCreditPurchaseRepository

func NewCreditPurchaseRepository(db *bun.DB) *CreditPurchaseRepository

func (*CreditPurchaseRepository) Create

Create creates a new credit purchase record.

func (*CreditPurchaseRepository) CreateWithTx

func (r *CreditPurchaseRepository) CreateWithTx(
	ctx context.Context,
	tx *bun.Tx,
	purchase *models.CreditPurchase,
) error

CreateWithTx creates a new credit purchase record within a transaction.

func (*CreditPurchaseRepository) DeleteByUserID

func (r *CreditPurchaseRepository) DeleteByUserID(ctx context.Context, tx *bun.Tx, userID string) error

DeleteByUserID deletes all credit purchases for a user within a transaction.

func (*CreditPurchaseRepository) GetByID

GetByID retrieves a credit purchase by ID.

func (*CreditPurchaseRepository) GetByStripeSessionID

func (r *CreditPurchaseRepository) GetByStripeSessionID(
	ctx context.Context,
	sessionID string,
) (*models.CreditPurchase, error)

GetByStripeSessionID retrieves a credit purchase by Stripe session ID.

func (*CreditPurchaseRepository) GetByUserID

func (r *CreditPurchaseRepository) GetByUserID(ctx context.Context, userID string) ([]models.CreditPurchase, error)

GetByUserID retrieves all credit purchases for a user.

func (*CreditPurchaseRepository) GetByUserIDWithPagination

func (r *CreditPurchaseRepository) GetByUserIDWithPagination(
	ctx context.Context,
	userID string,
	limit, offset int,
) ([]models.CreditPurchase, error)

GetByUserIDWithPagination retrieves credit purchases for a user with pagination.

func (*CreditPurchaseRepository) UpdateReceiptURLWithTx

func (r *CreditPurchaseRepository) UpdateReceiptURLWithTx(
	ctx context.Context,
	tx *bun.Tx,
	id string,
	receiptURL string,
) error

UpdateReceiptURLWithTx updates the receipt URL for a purchase.

func (*CreditPurchaseRepository) UpdateStatus

func (r *CreditPurchaseRepository) UpdateStatus(ctx context.Context, id string, status string) error

UpdateStatus updates the status of a credit purchase.

func (*CreditPurchaseRepository) UpdateStatusWithTx

func (r *CreditPurchaseRepository) UpdateStatusWithTx(ctx context.Context, tx *bun.Tx, id string, status string) error

UpdateStatusWithTx updates the status of a credit purchase within a transaction.

func (*CreditPurchaseRepository) UpdateStripePaymentIDWithTx

func (r *CreditPurchaseRepository) UpdateStripePaymentIDWithTx(
	ctx context.Context,
	tx *bun.Tx,
	id string,
	paymentID string,
) error

UpdateStripePaymentIDWithTx updates the Stripe payment ID for a purchase.

type CreditRepository

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

func NewCreditRepository

func NewCreditRepository(db *bun.DB) *CreditRepository

func (*CreditRepository) AddCreditsWithTx

func (r *CreditRepository) AddCreditsWithTx(
	ctx context.Context,
	tx *bun.Tx,
	userID string,
	freeCreditsToAdd int,
	paidCreditsToAdd int,
) error

AddCreditsWithTx atomically increments credits without a read-modify-write cycle. This prevents lost updates from concurrent operations.

func (*CreditRepository) BulkUpdateCreditUpdateNotices

func (r *CreditRepository) BulkUpdateCreditUpdateNotices(
	ctx context.Context,
	tx *bun.Tx,
	has int,
	needs int,
	reason string,
) error

func (*CreditRepository) BulkUpdateCredits

func (r *CreditRepository) BulkUpdateCredits(
	ctx context.Context,
	tx *bun.Tx,
	has int,
	needs int,
) error

func (*CreditRepository) CreateCreditAdjustmentWithTx

func (r *CreditRepository) CreateCreditAdjustmentWithTx(
	ctx context.Context,
	tx *bun.Tx,
	adjustment *models.CreditAdjustments,
) error

CreateCreditAdjustmentWithTx saves a new credit adjustment record.

func (*CreditRepository) DeductOneCreditWithTx

func (r *CreditRepository) DeductOneCreditWithTx(ctx context.Context, tx *bun.Tx, userID string) error

DeductOneCreditWithTx atomically deducts one credit, preferring free credits over paid credits. Returns an error if the user doesn't have sufficient credits.

func (*CreditRepository) DeleteCreditAdjustmentsByUserID

func (r *CreditRepository) DeleteCreditAdjustmentsByUserID(ctx context.Context, tx *bun.Tx, userID string) error

DeleteCreditAdjustmentsByUserID deletes all credit adjustments for a user within a transaction.

func (*CreditRepository) GetCreditAdjustmentsByUserID

func (r *CreditRepository) GetCreditAdjustmentsByUserID(
	ctx context.Context,
	userID string,
) ([]models.CreditAdjustments, error)

GetCreditAdjustmentsByUserID returns all credit adjustments for a user.

func (*CreditRepository) GetCreditAdjustmentsByUserIDWithPagination

func (r *CreditRepository) GetCreditAdjustmentsByUserIDWithPagination(
	ctx context.Context,
	userID string,
	limit, offset int,
) ([]models.CreditAdjustments, error)

GetCreditAdjustmentsByUserIDWithPagination returns credit adjustments for a user with pagination.

func (*CreditRepository) GetMostRecentCreditAdjustmentByReasonPrefix

func (r *CreditRepository) GetMostRecentCreditAdjustmentByReasonPrefix(
	ctx context.Context,
	reasonPrefix string,
) (*time.Time, error)

GetMostRecentCreditAdjustmentByReasonPrefix returns the most recent credit adjustment with reason starting with prefix.

type FacilitatorTokenRepo

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

func NewFacilitatorTokenRepo

func NewFacilitatorTokenRepo(db *bun.DB) FacilitatorTokenRepo

func (*FacilitatorTokenRepo) CleanUpExpiredTokens

func (r *FacilitatorTokenRepo) CleanUpExpiredTokens(ctx context.Context) error

func (*FacilitatorTokenRepo) GetToken

GetToken retrieves a token by its value.

func (*FacilitatorTokenRepo) SaveToken

SaveToken saves a facilitator token.

type InstanceRepository

type InstanceRepository interface {
	// Create saves an instance to the database
	Create(ctx context.Context, instance *models.Instance) error
	// CreateTx saves an instance to the database within a transaction
	CreateTx(ctx context.Context, tx *bun.Tx, instance *models.Instance) error

	// GetByID finds an instance by ID
	GetByID(ctx context.Context, id string) (*models.Instance, error)
	// FindByUserID finds all instances associated with a user ID
	FindByUserID(ctx context.Context, userID string) ([]models.Instance, error)
	// FindTemplates finds all instances that are templates
	FindTemplates(ctx context.Context, userID string) ([]models.Instance, error)

	// Update updates an instance in the database
	Update(ctx context.Context, instance *models.Instance) error

	// Delete deletes an instance from the database.
	// Deleting an instance cascades to all related data.
	Delete(ctx context.Context, tx *bun.Tx, id string) error
	// DeleteByUserID removes all instances associated with a user ID
	DeleteByUser(ctx context.Context, tx *bun.Tx, userID string) error

	// DismissQuickstart marks the user as having dismissed the quickstart
	DismissQuickstart(ctx context.Context, instanceID string) error
}

func NewInstanceRepository

func NewInstanceRepository(db *bun.DB) InstanceRepository

type InstanceSettingsRepository

type InstanceSettingsRepository interface {
	// Create new instance settings to the database
	Create(ctx context.Context, settings *models.InstanceSettings) error
	// CreateTx creates new instance settings within a transaction
	CreateTx(ctx context.Context, tx *bun.Tx, settings *models.InstanceSettings) error

	// Update updates an instance in the database
	Update(ctx context.Context, settings *models.InstanceSettings) error

	// Delete removes and instance from the database given the instanceID
	Delete(ctx context.Context, tx *bun.Tx, instanceID string) error

	// GetByInstanceID retrieves instance settings by instance ID
	GetByInstanceID(ctx context.Context, instanceID string) (*models.InstanceSettings, error)
}

func NewInstanceSettingsRepository

func NewInstanceSettingsRepository(db *bun.DB) InstanceSettingsRepository

type LocationRepository

type LocationRepository interface {
	// Create saves or updates a location
	Create(ctx context.Context, location *models.Location) error
	// CreateTx saves a location within a transaction
	CreateTx(ctx context.Context, tx *bun.Tx, location *models.Location) error
	// Update updates a location in the database
	Update(ctx context.Context, location *models.Location) error

	// GetByID finds a location by ID
	GetByID(ctx context.Context, locationID string) (*models.Location, error)
	// FindByIDs finds multiple locations by their IDs
	FindByIDs(ctx context.Context, instanceID string, locationIDs []string) ([]*models.Location, error)
	// FindByInstance finds a location by instance and code
	GetByInstanceAndCode(ctx context.Context, instanceID string, code string) (*models.Location, error)
	// GetByInstanceAndSlug finds a location by instance ID and slug
	GetByInstanceAndSlug(ctx context.Context, instanceID string, slug string) (*models.Location, error)
	// Find all locations for an instance
	FindByInstance(ctx context.Context, instanceID string) ([]models.Location, error)
	// FindLocationsByMarkerID finds all locations by marker ID
	FindLocationsByMarkerID(ctx context.Context, markerID string) ([]models.Location, error)

	// UpdateStatistics updates the statistics for an instance
	UpdateStatistics(ctx context.Context, tx *bun.Tx, instanceID string) error

	// Delete deletes a location from the database
	// Requires a transaction as related data will also need to be deleted
	Delete(ctx context.Context, tx *bun.Tx, locationID string) error
	// DeleteByInstance deletes all locations for an instance
	// Requires a transaction as related data will also need to be deleted
	DeleteByInstance(ctx context.Context, tx *bun.Tx, instanceID string) error

	// LoadRelations loads all relations for a location
	LoadRelations(ctx context.Context, location *models.Location) error
	// LoadMarker loads the marker for a location
	LoadMarker(ctx context.Context, location *models.Location) error
	// LoadInstance loads the instance for a location
	LoadInstance(ctx context.Context, location *models.Location) error
	// LoadBlocks loads the blocks for a location
	LoadBlocks(ctx context.Context, location *models.Location) error
}

func NewLocationRepository

func NewLocationRepository(db *bun.DB) LocationRepository

NewLocationRepository creates a new LocationRepository.

type MarkerRepository

type MarkerRepository interface {
	// Create a new marker in the database
	Create(ctx context.Context, marker *models.Marker) error

	// GetByCode finds a marker by its code
	GetByCode(ctx context.Context, code string) (*models.Marker, error)
	// FindNotInInstance finds markers that are not in an instance
	FindNotInInstance(ctx context.Context, instanceID string, otherInstances []string) ([]models.Marker, error)

	// Update updates a marker in the database
	Update(ctx context.Context, marker *models.Marker) error
	// UpdateCoords updates the latitude and longitude of a marker
	UpdateCoords(ctx context.Context, marker *models.Marker, lat, lng float64) error

	// Delete deletes a marker from the database
	// NOTE: Scheduled for removal
	Delete(ctx context.Context, code string) error
	// Deletes all unused markers
	DeleteUnused(ctx context.Context, tx *bun.Tx) error

	// IsShared checks if a marker is used by more than one location
	IsShared(ctx context.Context, code string) (bool, error)
	// UserOwnsMarker checks if a user owns a marker
	// NOTE: Scheduled for removal
	UserOwnsMarker(ctx context.Context, userID, markerCode string) (bool, error)
}

func NewMarkerRepository

func NewMarkerRepository(db *bun.DB) MarkerRepository

type NotificationRepository

type NotificationRepository interface {
	//	Create saves a notification to the database
	Create(context.Context, *models.Notification) error

	//	GetByID finds a notification by its ID
	GetByID(ctx context.Context, id string) (models.Notification, error)
	// FindByTeamCode finds all notifications for a specific team code
	FindByTeamCode(ctx context.Context, teamCode string) ([]models.Notification, error)

	//	Update updates a notification in the database
	Update(context.Context, *models.Notification) error
	// Dismiss marks a notification as dismissed
	Dismiss(ctx context.Context, id string) error

	//	Delete deletes a notification from the database
	Delete(ctx context.Context, id string) error
}

func NewNotificationRepository

func NewNotificationRepository(db *bun.DB) NotificationRepository

type PlayerStateData

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

PlayerStateData struct implements the PlayerState interface.

func (*PlayerStateData) GetBlockID

func (p *PlayerStateData) GetBlockID() string

func (*PlayerStateData) GetPlayerData

func (p *PlayerStateData) GetPlayerData() json.RawMessage

func (*PlayerStateData) GetPlayerID

func (p *PlayerStateData) GetPlayerID() string

func (*PlayerStateData) GetPointsAwarded

func (p *PlayerStateData) GetPointsAwarded() int

func (*PlayerStateData) IsComplete

func (p *PlayerStateData) IsComplete() bool

func (*PlayerStateData) SetComplete

func (p *PlayerStateData) SetComplete(complete bool)

func (*PlayerStateData) SetPlayerData

func (p *PlayerStateData) SetPlayerData(data json.RawMessage)

func (*PlayerStateData) SetPointsAwarded

func (p *PlayerStateData) SetPointsAwarded(points int)

type ShareLinkRepository

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

func NewShareLinkRepository

func NewShareLinkRepository(db *bun.DB) ShareLinkRepository

NewShareLinkRepository creates a new ShareLinkRepository.

func (*ShareLinkRepository) Create

func (r *ShareLinkRepository) Create(ctx context.Context, link *models.ShareLink) error

Create saves a new share link in the database.

func (*ShareLinkRepository) GetByID

GetByID retrieves a share link by its ID.

func (*ShareLinkRepository) Use

Use increments the used count for a share link.

type TeamRepository

type TeamRepository interface {
	// InsertBatch adds multiple teams to the database
	InsertBatch(ctx context.Context, teams []models.Team) error

	// GetByCode returns a team by its code
	GetByCode(ctx context.Context, code string) (*models.Team, error)
	// GetUserIDByCode returns the user ID associated with a team code
	GetUserIDByCode(ctx context.Context, code string) (string, error)
	// FindAll returns all teams for an instance
	FindAll(ctx context.Context, instanceID string) ([]models.Team, error)
	// FindAllWithScans returns all teams for an instance with scans
	FindAllWithScans(ctx context.Context, instanceID string) ([]models.Team, error)

	// Update saves or updates a team in the database
	Update(ctx context.Context, t *models.Team) error
	// UpdateTeamStartedWithTx sets the team's hasStarted field to true within a transaction
	UpdateTeamStartedWithTx(ctx context.Context, tx *bun.Tx, teamID string) error
	// Reset wipes a team's progress for re-use
	Reset(ctx context.Context, tx *bun.Tx, instanceID string, teamCodes []string) error

	// Delete removes the team from the database
	// Requires a transaction as related data will also need to be deleted
	Delete(ctx context.Context, tx *bun.Tx, instanceID string, teamCode string) error
	// DeleteByInstanceID removes all teams for a specific instance
	// Requires a transaction as this implies a cascade delete and related data
	// will also need to be deleted
	DeleteByInstanceID(ctx context.Context, tx *bun.Tx, instanceID string) error

	// LoadInstance loads the instance for a team
	LoadInstance(ctx context.Context, team *models.Team) error
	// LoadCheckIns loads the check-ins for a team
	LoadCheckIns(ctx context.Context, team *models.Team) error
	// LoadBlockingLocation loads the blocking location for a team
	LoadBlockingLocation(ctx context.Context, team *models.Team) error
	// LoadMessages loads the messages for a team
	LoadMessages(ctx context.Context, team *models.Team) error
	// LoadRelations loads all relations for a team
	LoadRelations(ctx context.Context, team *models.Team) error
}

func NewTeamRepository

func NewTeamRepository(db *bun.DB) TeamRepository

NewTeamRepository creates a new TeamRepository.

type TeamStartLogRepository

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

func NewTeamStartLogRepository

func NewTeamStartLogRepository(db *bun.DB) *TeamStartLogRepository

func (*TeamStartLogRepository) CreateWithTx

func (r *TeamStartLogRepository) CreateWithTx(ctx context.Context, tx *bun.Tx, log *models.TeamStartLog) error

CreateWithTx saves a new team start log entry.

func (*TeamStartLogRepository) DeleteByUserID

func (r *TeamStartLogRepository) DeleteByUserID(ctx context.Context, tx *bun.Tx, userID string) error

DeleteByUserID deletes all team start logs for a user within a transaction.

func (*TeamStartLogRepository) GetByUserID

func (r *TeamStartLogRepository) GetByUserID(ctx context.Context, userID string) ([]models.TeamStartLog, error)

GetByUserID returns all team start logs for a user.

func (*TeamStartLogRepository) GetByUserIDAndInstanceID

func (r *TeamStartLogRepository) GetByUserIDAndInstanceID(
	ctx context.Context,
	userID, instanceID string,
) ([]models.TeamStartLog, error)

GetByUserIDAndInstanceID returns team start logs for a user and specific instance.

func (*TeamStartLogRepository) GetByUserIDAndInstanceIDWithTimeframe

func (r *TeamStartLogRepository) GetByUserIDAndInstanceIDWithTimeframe(
	ctx context.Context,
	userID, instanceID string,
	startTime, endTime time.Time,
) ([]models.TeamStartLog, error)

GetByUserIDAndInstanceIDWithTimeframe returns team start logs for a user and instance within a timeframe.

func (*TeamStartLogRepository) GetByUserIDWithTimeframe

func (r *TeamStartLogRepository) GetByUserIDWithTimeframe(
	ctx context.Context,
	userID string,
	startTime, endTime time.Time,
) ([]models.TeamStartLog, error)

GetByUserIDWithTimeframe returns team start logs for a user within a timeframe.

type UploadsRepository

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

func NewUploadRepository

func NewUploadRepository(db *bun.DB) UploadsRepository

func (*UploadsRepository) Create

func (r *UploadsRepository) Create(ctx context.Context, upload *models.Upload) error

func (*UploadsRepository) Delete added in v6.1.0

func (r *UploadsRepository) Delete(ctx context.Context, uploadID string) error

Delete removes an upload record by ID.

func (*UploadsRepository) DeleteByBlockID added in v6.1.0

func (r *UploadsRepository) DeleteByBlockID(ctx context.Context, blockID string) error

DeleteByBlockID removes all upload records associated with a specific block.

func (*UploadsRepository) GetByBlockID added in v6.1.0

func (r *UploadsRepository) GetByBlockID(ctx context.Context, blockID string) ([]*models.Upload, error)

GetByBlockID retrieves all uploads associated with a specific block.

func (*UploadsRepository) GetOrphanedUploads added in v6.1.0

func (r *UploadsRepository) GetOrphanedUploads(ctx context.Context) ([]*models.Upload, error)

GetOrphanedUploads retrieves all uploads that reference non-existent blocks. This includes uploads where block_id is not null but the block doesn't exist.

func (*UploadsRepository) SearchByCriteria

func (r *UploadsRepository) SearchByCriteria(
	ctx context.Context,
	criteria map[string]string,
) ([]*models.Upload, error)

type UserRepository

type UserRepository interface {
	// Create creates a new user in the database
	Create(ctx context.Context, user *models.User) error

	// GetByEmail retrieves a user by their email address
	GetByEmail(ctx context.Context, email string) (*models.User, error)
	// GetByEmailToken retrieves a user by their email token
	GetByEmailToken(ctx context.Context, token string) (*models.User, error)
	// GetByID fetches a user by their ID from the database.
	GetByID(ctx context.Context, userID string) (*models.User, error)
	// GetByEmailAndProvider retrieves a user by their email address and provider
	GetByEmailAndProvider(ctx context.Context, email, provider string) (*models.User, error)

	// Update updates a user in the database
	Update(ctx context.Context, user *models.User) error

	// Delete deletes a user from the database
	// Requires a transaction as related data will also need to be deleted
	Delete(ctx context.Context, tx *bun.Tx, userID string) error
}

func NewUserRepository

func NewUserRepository(db *bun.DB) UserRepository

Jump to

Keyboard shortcuts

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