UP | HOME

Postmodern

Postmodern is a Postgres interaction library for CommonLisp. It lets you write CLOS objects like this object from Nebula:

(defclass entry ()
  ((uuid    :col-type string  :initarg :uuid    :accessor entry-uuid)
   (target  :col-type string  :initarg :target  :accessor entry-target)
   (created :col-type integer :initarg :created :accessor entry-created)
   (size    :col-type integer :initarg :size    :accessor entry-size)
   (parent  :col-type string  :initarg :parent  :accessor entry-parent))
  (:metaclass postmodern:dao-class) ; make this a database access object
  (:keys uuid)
  (:doc  "An entry associates some notion of a blob with additional data."))

And then do things like the below:

(defun-with-db store-entry (ent)
    (when (entry-p ent)
      (postmodern:insert-dao ent)))

  (defun select-by-target (identifier)
    (postmodern:select-dao 'entry (:= 'target identifier)))

  (unless (postmodern:table-exists-p 'entry)
          (postmodern:execute
           (postmodern:dao-table-definition 'entry))

Notes

I was trying to debug in a different project why postmodern:create-all-tables doesn't work, but running the Nebula code works. I think it's due to the usage of the `execute…` code instead.