Skip to content

Instantly share code, notes, and snippets.

@jmercouris
Created January 14, 2019 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmercouris/fea3a94aacae922a7977f9660eff204b to your computer and use it in GitHub Desktop.
Save jmercouris/fea3a94aacae922a7977f9660eff204b to your computer and use it in GitHub Desktop.
(defun get-products ()
(with-connection (db)
(let ((products (retrieve-all
(select (:id :name :short-description :price)
(from :product)))))
(loop for product in products
do (let* ((product-id (getf product :id))
(product-features (retrieve-all
(select (:feature :description)
(from :product-features)
(where (:= :product-id product-id))))))
(push product-features product)
(push :features product)))
products)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment