Documentation
¶
Overview ¶
Package repository provides implementations of repositories for the domain layer.
Index ¶
- func NewAccountRepository(q sqlc.Querier) domain.AccountRepository
- func NewAdminAuditRepository(q sqlc.Querier) domain.AdminAuditRepository
- func NewAdminTenantRepository(q sqlc.Querier) domain.AdminTenantRepository
- func NewAdminUserRepository(q sqlc.Querier) domain.AdminUserRepository
- func NewAuditRepository(q sqlc.Querier) domain.AuditRepository
- func NewAuthRepository(q sqlc.Querier) domain.AuthRepository
- func NewCategoryRepository(q sqlc.Querier) domain.CategoryRepository
- func NewMasterPurchaseRepository(q sqlc.Querier) domain.MasterPurchaseRepository
- func NewTenantRepository(q sqlc.Querier) domain.TenantRepository
- func NewTransactionRepository(q sqlc.Querier) domain.TransactionRepository
- func NewUserRepository(q sqlc.Querier) domain.UserRepository
- func TranslateError(err error) error
- type AssetRepo
- func (r *AssetRepo) Create(ctx context.Context, input domain.CreateAssetInput) (*domain.Asset, error)
- func (r *AssetRepo) Delete(ctx context.Context, id string) error
- func (r *AssetRepo) GetAssetWithTenantConfig(ctx context.Context, tenantID, id string) (*domain.Asset, error)
- func (r *AssetRepo) GetByID(ctx context.Context, id string) (*domain.Asset, error)
- func (r *AssetRepo) GetByTicker(ctx context.Context, ticker string) (*domain.Asset, error)
- func (r *AssetRepo) GetLastPrice(ctx context.Context, id string) (int64, error)
- func (r *AssetRepo) List(ctx context.Context, params domain.ListAssetsParams) ([]domain.Asset, error)
- type PortfolioSnapshotRepository
- func (r *PortfolioSnapshotRepository) Create(ctx context.Context, tenantID string, in domain.CreatePortfolioSnapshotInput) (*domain.PortfolioSnapshot, error)
- func (r *PortfolioSnapshotRepository) GetByDate(ctx context.Context, tenantID string, date time.Time) (*domain.PortfolioSnapshot, error)
- func (r *PortfolioSnapshotRepository) ListByTenant(ctx context.Context, tenantID string) ([]domain.PortfolioSnapshot, error)
- type PositionIncomeEventRepository
- func (r *PositionIncomeEventRepository) Create(ctx context.Context, tenantID string, in domain.CreatePositionIncomeEventInput) (*domain.PositionIncomeEvent, error)
- func (r *PositionIncomeEventRepository) GetByID(ctx context.Context, tenantID, id string) (*domain.PositionIncomeEvent, error)
- func (r *PositionIncomeEventRepository) ListByTenant(ctx context.Context, tenantID string) ([]domain.PositionIncomeEvent, error)
- func (r *PositionIncomeEventRepository) ListPending(ctx context.Context, tenantID string) ([]domain.PositionIncomeEvent, error)
- func (r *PositionIncomeEventRepository) UpdateStatus(ctx context.Context, tenantID, id string, status domain.ReceivableStatus, ...) (*domain.PositionIncomeEvent, error)
- type PositionRepository
- func (r *PositionRepository) Create(ctx context.Context, tenantID string, in domain.CreatePositionInput) (*domain.Position, error)
- func (r *PositionRepository) Delete(ctx context.Context, tenantID, id string) error
- func (r *PositionRepository) GetByID(ctx context.Context, tenantID, id string) (*domain.Position, error)
- func (r *PositionRepository) ListByAccount(ctx context.Context, tenantID, accountID string) ([]domain.Position, error)
- func (r *PositionRepository) ListByTenant(ctx context.Context, tenantID string) ([]domain.Position, error)
- func (r *PositionRepository) ListDueIncome(ctx context.Context, before time.Time) ([]domain.Position, error)
- func (r *PositionRepository) Update(ctx context.Context, tenantID, id string, in domain.UpdatePositionInput) (*domain.Position, error)
- type PositionSnapshotRepository
- func (r *PositionSnapshotRepository) Create(ctx context.Context, tenantID string, in domain.CreatePositionSnapshotInput) (*domain.PositionSnapshot, error)
- func (r *PositionSnapshotRepository) ListByPosition(ctx context.Context, tenantID, positionID string) ([]domain.PositionSnapshot, error)
- func (r *PositionSnapshotRepository) ListByTenantSince(ctx context.Context, tenantID string, since time.Time) ([]domain.PositionSnapshot, error)
- type TenantAssetConfigRepository
- func (r *TenantAssetConfigRepository) Delete(ctx context.Context, tenantID, assetID string) error
- func (r *TenantAssetConfigRepository) GetByAssetID(ctx context.Context, tenantID, assetID string) (*domain.TenantAssetConfig, error)
- func (r *TenantAssetConfigRepository) ListByTenant(ctx context.Context, tenantID string) ([]domain.TenantAssetConfig, error)
- func (r *TenantAssetConfigRepository) Upsert(ctx context.Context, tenantID string, ...) (*domain.TenantAssetConfig, error)
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 ¶
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
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
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
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
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
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
func (r *PortfolioSnapshotRepository) Create(ctx context.Context, tenantID string, in domain.CreatePortfolioSnapshotInput) (*domain.PortfolioSnapshot, error)
Create persists a new portfolio snapshot.
func (*PortfolioSnapshotRepository) GetByDate ¶ added in v1.15.0
func (r *PortfolioSnapshotRepository) GetByDate(ctx context.Context, tenantID string, date time.Time) (*domain.PortfolioSnapshot, error)
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
func (r *PositionIncomeEventRepository) Create(ctx context.Context, tenantID string, in domain.CreatePositionIncomeEventInput) (*domain.PositionIncomeEvent, error)
Create persists a new income event.
func (*PositionIncomeEventRepository) GetByID ¶ added in v1.15.0
func (r *PositionIncomeEventRepository) GetByID(ctx context.Context, tenantID, id string) (*domain.PositionIncomeEvent, error)
GetByID retrieves an income event by ID.
func (*PositionIncomeEventRepository) ListByTenant ¶ added in v1.15.0
func (r *PositionIncomeEventRepository) ListByTenant(ctx context.Context, tenantID string) ([]domain.PositionIncomeEvent, error)
ListByTenant lists all events for a tenant.
func (*PositionIncomeEventRepository) ListPending ¶ added in v1.15.0
func (r *PositionIncomeEventRepository) ListPending(ctx context.Context, tenantID string) ([]domain.PositionIncomeEvent, error)
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
func (r *PositionRepository) Create(ctx context.Context, tenantID string, in domain.CreatePositionInput) (*domain.Position, error)
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).
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
func (r *PositionSnapshotRepository) Create(ctx context.Context, tenantID string, in domain.CreatePositionSnapshotInput) (*domain.PositionSnapshot, error)
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
func (r *TenantAssetConfigRepository) Upsert(ctx context.Context, tenantID string, input domain.UpsertTenantAssetConfigInput) (*domain.TenantAssetConfig, error)
Upsert creates or updates a tenant asset configuration based on the provided input and returns the resulting configuration.
Source Files
¶
- account_repo.go
- admin_repo.go
- asset_repo.go
- audit_repo.go
- auth_repo.go
- category_repo.go
- master_purchase_repo.go
- portfolio_snapshot_repository.go
- position_income_event_repository.go
- position_repository.go
- position_snapshot_repository.go
- repository.go
- tenant_asset_config_repository.go
- tenant_repo.go
- transaction_repo.go
- user_repo.go