Reputation: 33
I am trying to add some data into app engine datastore. This is my function
(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"))))
Here I want to print false in body according to the value of isIdExist
function (which returns true if email already exists else false) now when I run this, If isIdExist == true
then it prints false but when isIdExist == false
it adds the value in datastore but gives this error. Can someone please help why it is happening and what concept of clojure am I missing here? Thanks
Upvotes: 1
Views: 1825
Reputation: 91534
In Clojure )))))))
is totally normal and you see it everywhere, no cause for concern.
On the other hand ((
should stand out and catch your eye. It very often means:
This pattern is not wrong in any way, just learning to spot it is a useful way to get used to reading Clojure code quickly. In this case it likely means there are too many opening (
s in
((db/addUser email phone roleId status) (str "true"))))
Upvotes: 4
Reputation: 144126
I assume db/addUser
returns a string in which case you're trying to invoke the return value as a function. It looks like you want to perform the insert then return "true" so you can use do
to sequence the two:
(if (db/isIdExist "users" "email" email)
"false"
(do
(db/addUser email phone roleId status)
"true"))))
Upvotes: 5