repository

package
v1.18.0 Latest Latest
Warning

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

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

Documentation

Overview

Package repository provides implementations of repositories for the domain layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccountRepository

func NewAccountRepository(q sqlc.Querier) domain.AccountRepository

NewAccountRepository creates a new concrete implementation of domain.AccountRepository.

func NewAdminAuditRepository

func NewAdminAuditRepository(q sqlc.Querier) domain.AdminAuditRepository

NewAdminAuditRepository creates a new concrete implementation of domain.AdminAuditRepository.

func NewAdminTenantRepository

func NewAdminTenantRepository(q sqlc.Querier) domain.AdminTenantRepository

NewAdminTenantRepository creates a new concrete implementation of domain.AdminTenantRepository.

func NewAdminUserRepository

func NewAdminUserRepository(q sqlc.Querier) domain.AdminUserRepository

NewAdminUserRepository creates a new concrete implementation of domain.AdminUserRepository.

func NewAuditRepository

func NewAuditRepository(q sqlc.Querier) domain.AuditRepository

NewAuditRepository creates a new AuditRepository.

func NewAuthRepository

func NewAuthRepository(q sqlc.Querier) domain.AuthRepository

NewAuthRepository creates a new concrete implementation of domain.AuthRepository.

func NewCategoryRepository

func NewCategoryRepository(q sqlc.Querier) domain.CategoryRepository

NewCategoryRepository creates a new concrete implementation of domain.CategoryRepository.

func NewMasterPurchaseRepository added in v1.10.0

func NewMasterPurchaseRepository(q sqlc.Querier) domain.MasterPurchaseRepository

NewMasterPurchaseRepository creates a new MasterPurchaseRepository implementation.

func NewTenantRepository

func NewTenantRepository(q sqlc.Querier) domain.TenantRepository

NewTenantRepository creates a new concrete implementation of domain.TenantRepository.

func NewTransactionRepository

func NewTransactionRepository(q sqlc.Querier) domain.TransactionRepository

NewTransactionRepository creates a new TransactionRepository.

func NewUserRepository

func NewUserRepository(q sqlc.Querier) domain.UserRepository

NewUserRepository creates a new concrete implementation of domain.UserRepository.

func TranslateError

func TranslateError(err error) error

TranslateError maps database-specific errors (pgx, postgres) to domain-specific errors.

Types

type AssetRepo added in v1.14.0

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

AssetRepo provides methods to manage financial assets in the database.

func NewAssetRepository added in v1.14.0

func NewAssetRepository(q sqlc.Querier) *AssetRepo

NewAssetRepository creates a new instance of AssetRepository with the provided sqlc.Querier.

func (*AssetRepo) Create added in v1.14.0

func (r *AssetRepo) Create(ctx context.Context, input domain.CreateAssetInput) (*domain.Asset, error)

Create adds a new asset to the database based on the provided input and returns the created asset.

func (*AssetRepo) Delete added in v1.14.0

func (r *AssetRepo) Delete(ctx context.Context, id string) error

Delete removes an asset from the database by its ID. If the deletion fails, it returns an error.

func (*AssetRepo) GetAssetWithTenantConfig added in v1.15.0

func (r *AssetRepo) GetAssetWithTenantConfig(ctx context.Context, tenantID, id string) (*domain.Asset, error)

GetAssetWithTenantConfig retrieves a global asset and applies any tenant-specific overrides from the database.

func (*AssetRepo) GetByID added in v1.14.0

func (r *AssetRepo) GetByID(ctx context.Context, id string) (*domain.Asset, error)

GetByID retrieves an asset by its unique ID. If the asset does not exist, it returns a domain.ErrAssetNotFound error.

func (*AssetRepo) GetByTicker added in v1.14.0

func (r *AssetRepo) GetByTicker(ctx context.Context, ticker string) (*domain.Asset, error)

GetByTicker retrieves an asset by its ticker symbol. If the asset does not exist, it returns a domain.ErrAssetNotFound error.

func (*AssetRepo) GetLastPrice added in v1.14.0

func (r *AssetRepo) GetLastPrice(ctx context.Context, id string) (int64, error)

GetLastPrice returns the most recent price for an asset. In a real app, this might call an external API.

func (*AssetRepo) List added in v1.14.0

func (r *AssetRepo) List(ctx context.Context, params domain.ListAssetsParams) ([]domain.Asset, error)

List returns a list of assets based on the provided filtering and pagination parameters. Currently, the sqlc ListAssets query does not support filtering/pagination, so this method returns all assets. If Phase 3 requires filtering/pagination, the SQL query and this method would need to be updated accordingly.

type PortfolioSnapshotRepository added in v1.15.0

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

PortfolioSnapshotRepository handles top-level portfolio aggregate state.

func NewPortfolioSnapshotRepository added in v1.15.0

func NewPortfolioSnapshotRepository(q sqlc.Querier) *PortfolioSnapshotRepository

NewPortfolioSnapshotRepository returns a new PortfolioSnapshotRepository instance.

func (*PortfolioSnapshotRepository) Create added in v1.15.0

Create persists a new portfolio snapshot.

func (*PortfolioSnapshotRepository) GetByDate added in v1.15.0

GetByDate retrieves a snapshot for a tenant on a date.

func (*PortfolioSnapshotRepository) ListByTenant added in v1.15.0

func (r *PortfolioSnapshotRepository) ListByTenant(ctx context.Context, tenantID string) ([]domain.PortfolioSnapshot, error)

ListByTenant lists all aggregate snapshots for a tenant.

type PositionIncomeEventRepository added in v1.15.0

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

PositionIncomeEventRepository handles receivables.

func NewPositionIncomeEventRepository added in v1.15.0

func NewPositionIncomeEventRepository(q sqlc.Querier) *PositionIncomeEventRepository

NewPositionIncomeEventRepository returns a new PositionIncomeEventRepository instance.

func (*PositionIncomeEventRepository) Create added in v1.15.0

Create persists a new income event.

func (*PositionIncomeEventRepository) GetByID added in v1.15.0

GetByID retrieves an income event by ID.

func (*PositionIncomeEventRepository) ListByTenant added in v1.15.0

ListByTenant lists all events for a tenant.

func (*PositionIncomeEventRepository) ListPending added in v1.15.0

ListPending lists pending events.

func (*PositionIncomeEventRepository) UpdateStatus added in v1.15.0

func (r *PositionIncomeEventRepository) UpdateStatus(
	ctx context.Context,
	tenantID, id string,
	status domain.ReceivableStatus,
	receivedAt *time.Time,
) (*domain.PositionIncomeEvent, error)

UpdateStatus transitions status.

type PositionRepository added in v1.15.0

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

PositionRepository handles holding persistence.

func NewPositionRepository added in v1.15.0

func NewPositionRepository(q sqlc.Querier) *PositionRepository

NewPositionRepository returns a new PositionRepository instance.

func (*PositionRepository) Create added in v1.15.0

Create persists a new position.

func (*PositionRepository) Delete added in v1.15.0

func (r *PositionRepository) Delete(ctx context.Context, tenantID, id string) error

Delete soft deletes a position.

func (*PositionRepository) GetByID added in v1.15.0

func (r *PositionRepository) GetByID(ctx context.Context, tenantID, id string) (*domain.Position, error)

GetByID retrieves a position by ID.

func (*PositionRepository) ListByAccount added in v1.15.0

func (r *PositionRepository) ListByAccount(ctx context.Context, tenantID, accountID string) ([]domain.Position, error)

ListByAccount lists positions for an account.

func (*PositionRepository) ListByTenant added in v1.15.0

func (r *PositionRepository) ListByTenant(ctx context.Context, tenantID string) ([]domain.Position, error)

ListByTenant lists positions for a tenant.

func (*PositionRepository) ListDueIncome added in v1.15.0

func (r *PositionRepository) ListDueIncome(ctx context.Context, before time.Time) ([]domain.Position, error)

ListDueIncome lists positions due for income globally (for scheduler).

func (*PositionRepository) Update added in v1.15.0

Update modifies a position.

type PositionSnapshotRepository added in v1.15.0

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

PositionSnapshotRepository handles holding state history.

func NewPositionSnapshotRepository added in v1.15.0

func NewPositionSnapshotRepository(q sqlc.Querier) *PositionSnapshotRepository

NewPositionSnapshotRepository returns a new PositionSnapshotRepository instance.

func (*PositionSnapshotRepository) Create added in v1.15.0

Create persists a new position snapshot.

func (*PositionSnapshotRepository) ListByPosition added in v1.15.0

func (r *PositionSnapshotRepository) ListByPosition(ctx context.Context, tenantID, positionID string) ([]domain.PositionSnapshot, error)

ListByPosition retrieves historical snapshots for a position.

func (*PositionSnapshotRepository) ListByTenantSince added in v1.15.0

func (r *PositionSnapshotRepository) ListByTenantSince(ctx context.Context, tenantID string, since time.Time) ([]domain.PositionSnapshot, error)

ListByTenantSince retrieves snapshots for a tenant since a date.

type TenantAssetConfigRepository added in v1.14.0

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

TenantAssetConfigRepository provides methods to manage tenant-specific asset configurations in the database.

func NewTenantAssetConfigRepository added in v1.14.0

func NewTenantAssetConfigRepository(q sqlc.Querier) *TenantAssetConfigRepository

NewTenantAssetConfigRepository creates a new instance of TenantAssetConfigRepository with the provided sqlc.Querier.

func (*TenantAssetConfigRepository) Delete added in v1.14.0

func (r *TenantAssetConfigRepository) Delete(ctx context.Context, tenantID, assetID string) error

Delete performs a soft delete of the tenant asset configuration by its asset ID and tenant ID.

func (*TenantAssetConfigRepository) GetByAssetID added in v1.14.0

func (r *TenantAssetConfigRepository) GetByAssetID(ctx context.Context, tenantID, assetID string) (*domain.TenantAssetConfig, error)

GetByAssetID retrieves a tenant asset configuration by its asset ID and tenant ID. If the configuration does not exist, it returns a domain.ErrAssetConfigNotFound error.

func (*TenantAssetConfigRepository) ListByTenant added in v1.14.0

func (r *TenantAssetConfigRepository) ListByTenant(ctx context.Context, tenantID string) ([]domain.TenantAssetConfig, error)

ListByTenant returns all tenant asset configurations for the given tenant ID.

func (*TenantAssetConfigRepository) Upsert added in v1.14.0

Upsert creates or updates a tenant asset configuration based on the provided input and returns the resulting configuration.

Jump to

Keyboard shortcuts

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