summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <dev@marius-peter.com>2025-10-23 16:35:53 +0200
committerMarius Peter <dev@marius-peter.com>2025-10-23 16:35:53 +0200
commit8da8e41420307810f855f0596ca4bb67d23afa0f (patch)
tree2a85e3817d45e29cd06d4920d802ddb90c401e08
parent0fc6231625943ad8b8faac8c0519f8599b5b8e84 (diff)
Nutrient creation returns the newly persisted instance.
-rw-r--r--models/nutrient.rkt5
1 files changed, 3 insertions, 2 deletions
diff --git a/models/nutrient.rkt b/models/nutrient.rkt
index 6bbaf56..8d38f74 100644
--- a/models/nutrient.rkt
+++ b/models/nutrient.rkt
@@ -7,7 +7,7 @@
nutrient-id nutrient-name nutrient-formula
;; SQL CRUD
(contract-out
- [create-nutrient! (-> string? string? void?)]
+ [create-nutrient! (-> string? string? nutrient?)]
[get-nutrients (-> (listof nutrient?))]
[get-nutrient (->* ()
(#:id (or/c #f exact-nonnegative-integer?)
@@ -35,7 +35,8 @@
(define (new-nutrient)
(query-exec (current-conn)
(insert #:into nutrients
- #:set [canonical_name ,name] [formula ,formula])))
+ #:set [canonical_name ,name] [formula ,formula]))
+ (get-nutrient #:name name))
(or existing-nutrient
(new-nutrient)))
Copyright 2019--2025 Marius PETER