(def database (atom
[{:orderid 0 :productid 0 :description "A" :amount 2 :state "active"}
{:orderid 1 :productid 1 :description "A" :amount 2 :state "active"}]))
(defn edit-order
[param-data]
(swap! database
(fn [old-orders]
(mapv (fn [order]
(if (= (:orderid order)
(:orderid param-data))
(assoc-in database [:state] "deleted")
order))
old-orders)))
)
(edit-order 0)
I want to replace the "active" to "deleted" after I give the Order ID. I tried with assoc-in, but it doesn't work. Thanks for helping.
if
there you access param-data like a map to get the :order-id from it. – cfrick