Would be nice to see the newest job postings at the top of the index page rather than at the bottom. The query doesn't specify an order, so it just gets results back in index order.
Let's add ORDER BY published_at DESC to the getAllJobs func.
func getAllJobs(db *sqlx.DB) ([]Job, error) {
var jobs []Job
- err := db.Select(&jobs, "SELECT * FROM jobs")
+ err := db.Select(&jobs, "SELECT * FROM jobs ORDER BY published_at DESC")
if err != nil && !errors.Is(err, sql.ErrNoRows) {
return jobs, err
}
return jobs, nil
}
Would be nice to see the newest job postings at the top of the index page rather than at the bottom. The query doesn't specify an order, so it just gets results back in index order.
Let's add
ORDER BY published_at DESC
to thegetAllJobs
func.