diff options
| author | Marius Peter <dev@marius-peter.com> | 2025-10-23 16:35:53 +0200 | 
|---|---|---|
| committer | Marius Peter <dev@marius-peter.com> | 2025-10-23 16:35:53 +0200 | 
| commit | 8da8e41420307810f855f0596ca4bb67d23afa0f (patch) | |
| tree | 2a85e3817d45e29cd06d4920d802ddb90c401e08 /models/nutrient.rkt | |
| parent | 0fc6231625943ad8b8faac8c0519f8599b5b8e84 (diff) | |
Nutrient creation returns the newly persisted instance.
Diffstat (limited to 'models/nutrient.rkt')
| -rw-r--r-- | models/nutrient.rkt | 5 | 
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)))  |