Skip to content

Instantly share code, notes, and snippets.

@dmozzy
Created May 11, 2012 14:22
Show Gist options
  • Save dmozzy/2659990 to your computer and use it in GitHub Desktop.
Save dmozzy/2659990 to your computer and use it in GitHub Desktop.
Adding user to the persistence.clj file
;Loads all locations. Retrieves the location field map for all locations
; and then adds in the locationId key value pair for each location.
(defn get-all-locations [user]
(map
(fn [k]
(assoc (:location k) :locationId (ds/key-id k)));This line sets the id onto the map at load time
(ds/query :kind Location :filter (= :user user))))
;Deletes a location by locationId, note we need to check that the user is the one who owns the location
(defn delete-location [user locationId]
(let [location (ds/retrieve Location locationId)]
(if (= (:user location) user)
(ds/delete! location))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment