   [id :as {{:keys [description name public_perms]} :body}]
   {name NonEmptyString, public_perms PublicPerms}
   (write-check Dashboard id)
-  (check-500 (upd-non-nil-keys Dashboard id
-                               :description description
-                               :name name))
-  (events/publish-event :dashboard-update (assoc (sel :one Dashboard :id id) :actor_id *current-user-id*)))
+  (check-500 (db/upd-non-nil-keys Dashboard id
+                                  :description description
+                                  :name name))
+  (events/publish-event :dashboard-update (assoc (db/sel :one Dashboard :id id) :actor_id *current-user-id*)))
 
 (defendpoint DELETE "/:id"
   "Delete a `Dashboard`."
   [id]
   (write-check Dashboard id)
   ;; TODO - it would be much more natural if `cascade-delete` returned the deleted entity instead of an api response
-  (let [dashboard (sel :one Dashboard :id id)
-        result (cascade-delete Dashboard :id id)]
+  (let [dashboard (db/sel :one Dashboard :id id)
+        result    (db/cascade-delete Dashboard :id id)]
     (events/publish-event :dashboard-delete (assoc dashboard :actor_id *current-user-id*))
     result))
 

  [:as {{:keys [name description public_perms] :as body} :body}]
  {name         [Required NonEmptyString]
   public_perms [Required PublicPerms]}
  (->> (ins Dashboard
            :name name
            :description description
            :public_perms public_perms
            :creator_id *current-user-id*)
       (events/publish-event :dashboard-create)))

(defendpoint GET "/:id"

  [id :as {{:keys [cardId]} :body}]
  {cardId [Required Integer]}
  (write-check Dashboard id)
  (check-400 (db/exists? Card :id cardId))
  (let [result (db/ins DashboardCard :card_id cardId, :dashboard_id id)]
    (events/publish-event :dashboard-add-cards {:id id :actor_id *current-user-id* :dashcards [result]})
    result))

