lots of progress
This commit is contained in:
@@ -97,7 +97,11 @@
|
||||
:long empty->nil
|
||||
'nat-int? empty->nil}}))
|
||||
|
||||
(def entity-id (mc/schema [nat-int? {:error/message "required"} ]))
|
||||
(def entity-id (mc/schema [nat-int? {:error/message "required"
|
||||
:decode/arbitrary (fn [e]
|
||||
(if (and (map? e) (:db/id e))
|
||||
(:db/id e)
|
||||
e))} ]))
|
||||
|
||||
(def temp-id (mc/schema [:string {:min 1}]))
|
||||
(def money (mc/schema [:double]))
|
||||
@@ -116,15 +120,17 @@
|
||||
|
||||
(def map->db-id-decoder
|
||||
{:enter (fn [x]
|
||||
(into []
|
||||
(for [[k v] (sort-by (comp #(Long/parseLong %) name first) x)]
|
||||
v
|
||||
#_(assoc v :db/id (cond (and (string? k) (re-find #"^\d+$" k))
|
||||
(Long/parseLong k)
|
||||
(keyword? k)
|
||||
(name k)
|
||||
:else
|
||||
k)))))})
|
||||
(if (sequential? x)
|
||||
x
|
||||
(into []
|
||||
(for [[k v] (sort-by (comp #(Long/parseLong %) name first) x)]
|
||||
v
|
||||
#_(assoc v :db/id (cond (and (string? k) (re-find #"^\d+$" k))
|
||||
(Long/parseLong k)
|
||||
(keyword? k)
|
||||
(name k)
|
||||
:else
|
||||
k))))))})
|
||||
|
||||
(defn many-entity [params & keys]
|
||||
(mc/schema
|
||||
@@ -219,7 +225,10 @@
|
||||
(handler request))))
|
||||
|
||||
(defn ref->enum-schema [n]
|
||||
(into [:enum {:decode/string #(keyword n %)}]
|
||||
(into [:enum {:decode/string #(if (keyword? %)
|
||||
%
|
||||
(keyword n %)
|
||||
)}]
|
||||
(for [{:db/keys [ident]} (all-schema)
|
||||
:when (= n (namespace ident))]
|
||||
ident)))
|
||||
|
||||
Reference in New Issue
Block a user