Browse Source

start implementing the CRUD functions for the /archive routes.

I still need to write the edit and delete functions (I.E. the 'U' and
'D' in 'CRUD') to have a basic CRUD system in place for this
section. I'm commiting this as an part of an end-of-session commit,
hence the partical amount of work done.
stable
Craig Oates 2 years ago
parent
commit
ffd483411c
  1. 33
      src/nera.lisp

33
src/nera.lisp

@ -36,7 +36,10 @@
#:get-storage-file
#:get-all-storage-files
#:rename-storage-file
#:delete-storage-file))
#:delete-storage-file
#:get-all-archive-entries
#:create-archive-entry
#:get-archive-entry))
(in-package #:nera-db)
(defparameter *tables* '(user site-settings page storage-file archive-entry)
@ -273,3 +276,31 @@ slug is updated based on `NEW-FILE-NAME'."
(if (null slug)
(mito:delete-by-values 'files:storage-file :name name)
(mito:delete-by-values 'files:storage-file :slug slug))))
(defun get-all-archive-entries ()
"Returns a list of all `ARCHIVE-ENTRY' entries in the database."
(with-connection (db)
(mito:select-dao 'archive:archive-entry
(sxql:order-by (:asc :title)))))
(defun create-archive-entry (title search-id slug thumbnail-slug thumbnail-file-type keywords)
"Add a new `ARCHIVE-ENTRY' to the database."
(with-connection (db)
(mito:create-dao 'archive:archive-entry
:title title
:search-id search-id
:slug slug
:thumbnail-slug thumbnail-slug
:thumbnail-file-type thumbnail-file-type
:keywords keywords)))
(defun get-archive-entry (&key id title slug)
"Returns a `ARCHIVE-ENTRY' from the database."
(with-connection (db)
(cond ((and (not title) (not slug))
(mito:find-dao 'archive:archive-entry :id id))
((and (not id) (not slug))
(mito:find-dao 'archive:archive-entry :title title))
((and (not id) (not title))
(mito:find-dao 'archive:archive-entry :slug slug))
(t nil))))

Loading…
Cancel
Save