From 8da8e41420307810f855f0596ca4bb67d23afa0f Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Thu, 23 Oct 2025 16:35:53 +0200 Subject: Nutrient creation returns the newly persisted instance. --- models/nutrient.rkt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'models/nutrient.rkt') 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))) -- cgit v1.2.3