Nutrient creation returns the newly persisted instance.

Commit
8da8e41420307810f855f0596ca4bb67d23afa0f
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
models/nutrient.rkt
index 6bbaf569..8d38f74f 100644..100644
@@ -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