@@ -135,7 +135,13 @@ export function createListingRepository(db) {
|
||||
|
||||
const offset = (page - 1) * limit;
|
||||
const sortOrder =
|
||||
sort === "price_low"
|
||||
sort === "updated"
|
||||
? desc(listings.updatedAt)
|
||||
: sort === "name_asc"
|
||||
? products.name
|
||||
: sort === "name_desc"
|
||||
? desc(products.name)
|
||||
: sort === "price_low"
|
||||
? listings.askingPriceMinor
|
||||
: sort === "price_high"
|
||||
? desc(listings.askingPriceMinor)
|
||||
|
||||
@@ -58,8 +58,8 @@ export function createSearchQuery({
|
||||
throw new Error("minPriceMinor must be <= maxPriceMinor");
|
||||
}
|
||||
|
||||
if (!["recent", "price_low", "price_high"].includes(sort)) {
|
||||
throw new Error("sort must be recent, price_low, or price_high");
|
||||
if (!["recent", "updated", "name_asc", "name_desc", "price_low", "price_high"].includes(sort)) {
|
||||
throw new Error("sort must be recent, updated, name_asc, name_desc, price_low, or price_high");
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user