与Cassaforte完全合格的名字

时间:2015-03-24 11:49:10

标签: clojure cassandra

使用Cassaforte的CQL DSL时,有没有办法完成一个完全限定的表名?

我目前有这个代码:

(defn get-data-by-user-id [client-name client-id user-id]
    (cql/use-keyspace (get-session) client-name)
    (cql/select (get-session) "some_data"
                (where [[= :client_id client-id] [= :user_id user-id]])
                (limit 1)))

我很好奇是否有可能做类似于Korma的事情,例如:

(defn get-data-by-user-id [client-name client-id user-id]
    (cql/select (get-session) "some_data"
                (where [[= :client_id client-id] [= :user_id user-id]])
                (limit 1)
                (keyspace client-name)))

1 个答案:

答案 0 :(得分:1)

cassaforte使用/别名hayt internaly为它的DSL(我创建了这个lib),所以是的,可能看到:

https://github.com/mpenet/hayt/blob/master/test/qbits/hayt/core_test.clj#L26-L27

或者如果您不需要转义/引用,只需使用关键字:

:foo.bar等

用作cql标识符的clojure关键字永远不会被转义。