summaryrefslogtreecommitdiff
path: root/models/fertilizer-product.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'models/fertilizer-product.rkt')
-rw-r--r--models/fertilizer-product.rkt28
1 files changed, 6 insertions, 22 deletions
diff --git a/models/fertilizer-product.rkt b/models/fertilizer-product.rkt
index 254ce35..073ef4f 100644
--- a/models/fertilizer-product.rkt
+++ b/models/fertilizer-product.rkt
@@ -13,12 +13,7 @@
number?)))
(string?)
fertilizer-product?)]
- [get-fertilizer-products (->* ()
- (#:id
- (or/c #f exact-nonnegative-integer?)
- #:brand-name
- (or/c #f string?))
- (listof fertilizer-product?))]
+ [get-fertilizer-products (-> (listof fertilizer-product?))]
[get-fertilizer-product (->* ()
(#:id
(or/c #f exact-nonnegative-integer?)
@@ -85,23 +80,12 @@
;; READ
-(define (get-fertilizer-products #:id [id #f]
- #:brand-name [brand-name #f])
- (define (where-expr)
- (define clauses
- (filter values
- (list (and id (format "id = ~e" id))
- (and brand-name (format "brand_name = ~e" brand-name)))))
- (cond
- [(null? clauses) ""]
- [else (format "WHERE ~a" (string-join clauses " AND "))]))
- (define query (string-join
- `("SELECT id, brand_name"
- "FROM fertilizer_products"
- ,(where-expr)
- "ORDER BY id ASC")))
+(define (get-fertilizer-products)
(for/list ([(id* brand-name*)
- (in-query (current-conn) query)])
+ (in-query (current-conn)
+ (select id brand_name
+ #:from fertilizer_products
+ #:order-by canonical_name #:asc))])
(fertilizer-product id* brand-name*)))
(define (get-fertilizer-product #:id [id #f]
Copyright 2019--2025 Marius PETER