使用clojure-monger查询mongo使用joda.time.datetime

时间:2014-10-16 12:15:57

标签: mongodb clojure monger

在尝试使用{$lte start $gte end}查询obj时出现此错误代码,您能告诉我一些使用coda.datetime查询的示例吗?

IllegalArgumentException can't serialize class org.joda.time.DateTime org.bson.BasicBSONEncoder._putObjectField (BasicBSONEncoder.java:284)

Func:

(defn data->orders [start end]
  (let [db (mg/get-db conn/mongo-db "db")
        coll "coll"
        formatter (f/formatter "YYYY-MM-dd")]
    (mc/find-maps db coll
                  {:created_at
                   {$gte (f/parse formatter start)
                    $lte (f/parse formatter end)}})))

1 个答案:

答案 0 :(得分:2)