package repository import ( "database/sql" "fmt" models "vibeStonk/server/models/v1" ) type HoldingRepo interface { // GetAll returns all holdings (purchases with sold quantity information) GetAll() ([]*models.Holding, error) // GetUnsold returns holdings that are not fully sold (including partially sold) GetUnsold() ([]*models.Holding, error) // GetSold returns holdings that are fully sold GetSold() ([]*models.Holding, error) // GetByID returns a specific holding by purchaseID GetByID(purchaseID int64) (*models.Holding, error) // GetByStockID returns holdings for a specific stock GetByStockID(stockID int64) ([]*models.Holding, error) // GetUnsoldByStockID returns unsold holdings for a specific stock ID GetUnsoldByStockID(stockID int64) ([]*models.Holding, error) // GetSoldByStockID returns sold holdings for a specific stock ID GetSoldByStockID(stockID int64) ([]*models.Holding, error) } func NewHoldingRepo(config *Config, db *sql.DB) (HoldingRepo, error) { switch config.DBEngine { case Sqlite: repo, err := newSqliteHoldingRepo(db) if err != nil { return nil, fmt.Errorf(errMsgFailed, "Sqlite", err) } return repo, nil default: return nil, ErrBadEngine } }