Created
May 11, 2012 14:22
-
-
Save dmozzy/2659990 to your computer and use it in GitHub Desktop.
Adding user to the persistence.clj file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;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