如何访问为 clojure jdbc insert 生成的密钥
How to access generated key for clojure jdbc insert
如何从返回的地图中获取生成的密钥。它似乎以“()”结尾,我似乎不能像普通钥匙那样使用它。
(defn create-map-db [mapname]
(insert! db-settings :MAP_TABLE {:M_NAME mapname})
)
(first (create-map-db "Moskau"))
=> {:scope_identity() 3}
(type (first (create-map-db "Moskau")))
=> clojure.lang.PersistentArrayMap
(get (first (create-map-db "Moskau")) :scope_identity())
=> ()
(get (first (create-map-db "Moskau")) :scope_identity)
=> nil
我认为最便携的解决方案如下所示:
(first (vals (first (create-map-db "Moskau"))))
但如果您真的想要,您可以直接使用以下方式访问密钥:
(def generated-key (keyword "scope_identity()"))
(generated-key (first (create-map-db "Moskau")))
也可用于获取所有生成的密钥:
(map generated-key (create-map-db "Moskau"))
如何从返回的地图中获取生成的密钥。它似乎以“()”结尾,我似乎不能像普通钥匙那样使用它。
(defn create-map-db [mapname]
(insert! db-settings :MAP_TABLE {:M_NAME mapname})
)
(first (create-map-db "Moskau"))
=> {:scope_identity() 3}
(type (first (create-map-db "Moskau")))
=> clojure.lang.PersistentArrayMap
(get (first (create-map-db "Moskau")) :scope_identity())
=> ()
(get (first (create-map-db "Moskau")) :scope_identity)
=> nil
我认为最便携的解决方案如下所示:
(first (vals (first (create-map-db "Moskau"))))
但如果您真的想要,您可以直接使用以下方式访问密钥:
(def generated-key (keyword "scope_identity()"))
(generated-key (first (create-map-db "Moskau")))
也可用于获取所有生成的密钥:
(map generated-key (create-map-db "Moskau"))