[Racket] Ferti hydroponic nutrient solver, redux.
Nutrient creation returns the newly persisted instance.
models/nutrient.rkt
@@ -7,7 +7,7 @@
7
7
nutrient-id nutrient-name nutrient-formula
8
8
;; SQL CRUD
9
9
(contract-out
10
Removed:
[create-nutrient! (-> string? string? void?)]
10
Added:
[create-nutrient! (-> string? string? nutrient?)]
11
11
[get-nutrients (-> (listof nutrient?))]
12
12
[get-nutrient (->* ()
13
13
(#:id (or/c #f exact-nonnegative-integer?)
@@ -35,7 +35,8 @@
35
35
(define (new-nutrient)
36
36
(query-exec (current-conn)
37
37
(insert #:into nutrients
38
Removed:
#:set [canonical_name ,name] [formula ,formula])))
38
Added:
#:set [canonical_name ,name] [formula ,formula]))
39
Added:
(get-nutrient #:name name))
39
40
(or existing-nutrient
40
41
(new-nutrient)))
41
42