2013-06-20 56 views
1

我是Clojure的新手,我遇到了Monger問題。不讓Monger序列化

我正在嘗試與朋友一起使用Monger。我有這個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) 

當我嘗試這與

(mc/insert "users" {:username "friend", 
        :password "$2a$10$YGcqRFL67J5NDo7hfkVslerDYc1iIGBy0js871wxnXxOvdvJZ4Aua", 
        :pin "1234", 
        :roles #{:cemerick.friend-demo.users/user}}) 

蒙格序列化添加到使用蒙格數據庫#{:cemerick.friend-demo.users/user}"user"有沒有什麼辦法可以把該值作爲是或有什麼辦法將"user"更改爲#{:cemerick.friend-demo.users/user}

回答

1

它可能會返回"user",因爲name函數只返回名稱。

(name :cemerick.friend-demo.users/user) 
;=> "user" 

你可以擺脫它們插入到數據庫之前,呼籲每個關鍵字str

(str :cemerick.friend-demo.users/user) 
;=> ":cemerick.friend-demo.users/user"