 (defn add-event-to-channel-db
   [channel-id event]
   (let [event-id (mu/object-id)]
-    (mc/insert-and-return mongodb
-                          coll-events
-                          (assoc event :_id event-id :channel-id channel-id))))
+    (export-data (mc/insert-and-return mongodb
+                                       coll-events
+                                       (assoc event :_id event-id :channel-id channel-id)))))
 
 (defn get-event
   [event-id]
-  (mc/find-map-by-id mongodb
-                     coll-events
-                     (mu/object-id event-id)))
-
-(defn clean-id
+  (export-data (mc/find-map-by-id mongodb
+                                  coll-events
+                                  (mu/object-id event-id))))
+
+(defn import-data
   [data]
-  (assoc data :_id (str (:_id data))))
+  (if-let [id (:id data)]
+    (assoc (dissoc data :id) :_id id)))
+
+(defn export-data
+  [data]
+  (dissoc (assoc data :id (str (:_id data))) :_id))
 
 ;; HTTP
 (def firebase-send-uri "https://fcm.googleapis.com/fcm/send")

  :known-content-type? #(check-content-type % [application-json])
  :malformed? #(parse-json % ::data)
  :post! (fn [context]
           (let [event (add-event-to-channel channel-id (::data context))]
            {:location (build-entry-url context
                                        "/events"
                                        (:_id event))})))

(defresource channel-subscribers [channel-id]
  :allowed-methods [:post]

             (if-let [event (get-event event-id)]
               {::data event}
               false))
  :handle-ok #(::data %))

(defroutes assemble-routes
  (GET "/" [] "Hello World2")
