Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToDomainVehicles ¶
ToDomainVehicles converts a slice of Vehicle objects to a slice of domain.Vehicle objects.
Types ¶
type Vehicle ¶
type Vehicle struct { Year int `gorm:"index:idx_year" json:"year,omitempty"` Month int `gorm:"index:idx_month" json:"month,omitempty"` FipeCode string `gorm:"index:idx_fipe_code" json:"fipe_code,omitempty"` Brand string `json:"brand,omitempty"` VehicleModel string `json:"vehicle_model,omitempty"` YearModel string `json:"year_model,omitempty"` Authentication string `json:"authentication,omitempty"` MeanValue float32 `json:"mean_value,omitempty"` }
type VehicleRepositoryPostgres ¶
func NewVehicleRepositoryPostgres ¶
func NewVehicleRepositoryPostgres(conn *gorm.DB) *VehicleRepositoryPostgres
NewVehicleRepositoryPostgres initializes a new instance of VehicleRepositoryPostgres with the given database connection. It performs automatic migrations for the Vehicle model and panics if an error occurs during migration. Returns a pointer to the VehicleRepositoryPostgres instance.
func (VehicleRepositoryPostgres) GetVehicle ¶
func (v VehicleRepositoryPostgres) GetVehicle( whereClauses []domain.WhereClause, orderByClauses []domain.OrderByClause, pagination domain.Pagination) ([]domain.Vehicle, *errs.AppError)
GetVehicle retrieves vehicles from the database based on the given conditions, order by specifications and pagination settings. It validates the pagination parameters and returns an error if they are invalid. It then fetches the vehicles from the database using the fetchVehiclesFromDb function, passing the specified conditions, order by specifications, and pagination settings. If an error occurs during the fetch operation, it returns the error. Otherwise, it converts the fetched vehicles to domain.Vehicle objects using the ToDomainVehicles function and returns them along with a nil error.