java.lang.String无法强制转换为clojure.lang.IFn

div*_*gar 1 clojure compojure clojure-java-interop clojurescript

我正在尝试将一些数据添加到app引擎数据存储区中.这是我的功能

(defn createUser [email phone roleId status]
  (println (db/isIdExist "users" "email" email))
  (if (db/isIdExist "users" "email" email) 
    (str "false")
    ((db/addUser email phone roleId status) (str "true"))))
Run Code Online (Sandbox Code Playgroud)

在这里我想根据isIdExist函数的值打印false (如果电子邮件已经存在,则返回true,否则为false)现在当我运行它时,如果isIdExist == true那时它打印为false但是当isIdExist == false它在数据存储区中添加值但是给出了这个错误.有人可以帮助为什么会发生这种情况,我在这里错过了什么概念?谢谢

Lee*_*Lee 5

我假设db/addUser返回一个字符串,在这种情况下,您尝试将返回值作为函数调用.看起来你想要执行插入然后返回"true",这样你就可以使用它do来对两者进行排序:

(if (db/isIdExist "users" "email" email) 
  "false"
  (do
    (db/addUser email phone roleId status) 
    "true"))))
Run Code Online (Sandbox Code Playgroud)