January 2014
Intermediate to advanced
232 pages
5h 11m
English
We now have all the pieces in place to start displaying the pictures in our gallery. We simply have to load all the thumbnails associated with the user and show them on the page. When clicked, a thumbnail will display the full-size picture.
Since we store references to uploaded images in the database, we can easily write a function to query all images with the given user ID in our db namespace.
| picture-gallery-d/src/picture_gallery/models/db.clj | |
| | (defn images-by-user [userid] |
| | (with-db |
| | sql/with-query-results |
| | res ["select * from images where userid = ?" userid] (doall res))) |
Let’s test that the function does what we intended by running it against a user we registered earlier and see if we get a list of ...
Read now
Unlock full access