(mc/update "tma" { :_id (ObjectId. (:_id item)) } item)))))
When I use pprint on "item", I can see that :_id is a string:
{:submit "Submit",
:scheduled-for-deletion "false",
"created-at[month]" "10",
:in-response-to-item-name "wpquestions-discourse-10",
:previous-item-name "",
"created-at[day]" "31",
"updated-at[m]" "30",
:this-user-is-disabled "false",
"updated-at[year]" "",
"updated-at[h]" "5",
:item-type "discourses",
:admin-note "",
"created-at[ampm]" "pm",
:private "false",
:user-item-name "wpquestions-sf_guard_user-2",
"created-at[m]" "30",
"updated-at[month]" "10",
:_id "52a50ce3e4b04252e29e7cc1",
"updated-at[day]" "31",
"created-at[h]" "5",
:item-name "wpquestions-discourse-11",
:community-item-name "wpquestions",
:machine-cookie-item-name "",
"created-at[year]" "",
:description "WE LOVE YOUR IDEA",
"updated-at[ampm]" "pm"}
This function was working a month ago, but I've made some change that apparently broke it. I can not figure out what change has broken it:
(defn persist-this-item [item]
{:pre [
(map? item)
(= (type (:item-name item)) java.lang.String)
(= (type (:item-type item)) java.lang.String)
(if (:created-at item)
(= (type (:created-at item)) org.joda.time.DateTime)
true)
]}
(println "This was given to monger/persist-this-item:")
(pp/pprint item)
(let [item (if (nil? (:created-at item))
(assoc item :created-at (dates/current-time-as-datetime))
item)
item (assoc item :updated-at (dates/current-time-as-datetime))]
(if (nil? (:_id item))
(do
(println " in monger/persist-this-item, we will now do an insert: ")
(mc/insert "tma" (assoc item :_id (ObjectId.))))
(do
(println " in monger/persist-this-item, we will now do an update: ")
(mc/update "tma" { :_id (ObjectId. (:_id item)) } item)))))