I'm new to Clojure and I'm having issues with Monger.
I'm trying to user Monger with Friend. I have this ns:
(ns cemerick.friend-demo.users
(:require [cemerick.friend.credentials :refer (hash-bcrypt)]))
(def users (atom {"friend" {:username "friend"
:password (hash-bcrypt "clojure")
:pin "1234" ;; only used by multi-factor
:roles #{::user}}
"friend-admin" {:username "friend-admin"
:password (hash-bcrypt "clojure")
:pin "1234" ;; only used by multi-factor
:roles #{::admin}}
(derive ::admin ::user)
When I try to add this to database using Monger with
(mc/insert "users" {:username "friend",
:password "$2a$10$YGcqRFL67J5NDo7hfkVslerDYc1iIGBy0js871wxnXxOvdvJZ4Aua",
:pin "1234",
:roles #{:cemerick.friend-demo.users/user}})
Monger serializes #{:cemerick.friend-demo.users/user}
as "user"
Is there any way to put that value as is or is there any way to change "user"
to #{:cemerick.friend-demo.users/user}
?
It's probably returning "user"
because the name
function returns only the name.
(name :cemerick.friend-demo.users/user)
;=> "user"
You could get away with calling str
on each keyword before inserting them into the database.
(str :cemerick.friend-demo.users/user)
;=> ":cemerick.friend-demo.users/user"