Commit 1d8c818d authored by ryszard.szopa's avatar ryszard.szopa
Browse files

select-dao

darcs-hash:d15e5826f6b14c18e62a87b3c89f72a00d3a219a
parent c01c9628
......@@ -85,6 +85,19 @@ with the database."
(assert (equal value-from-init value-from-db))))
(setf (slot-value dao (slot-definition-name slot)) value-from-db)))))
(defun select-dao-fun (type test)
"Functional interface for SELECT-DAO."
(with-class-connection ((find-class type))
(mapcar (lambda (x) (make-instance type :id (car x)))
(postmodern:query (:select 'id :from type :where (:raw (if (stringp test)
test
(sql-compile test))))))))
(defmacro select-dao (type &optional (test t))
"Select daos for the rows in its table for which the given test
holds."
`(select-dao-fun ,type ',test))
(defgeneric delete-dao (dao)
(:documentation "Delete the given dao from the database."))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment