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) 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 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) 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 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.