diff --git a/src/nera.lisp b/src/nera.lisp index 321d489..68f8b46 100644 --- a/src/nera.lisp +++ b/src/nera.lisp @@ -45,7 +45,9 @@ #:latest-archive-editted-entries #:latest-editted-pages #:latest-storage-editted-files - #:update-single-nav-menu-item)) + #:update-single-nav-menu-item + #:get-newer-archive-entries + #:get-older-archive-entries)) (in-package #:nera-db) (defparameter *tables* '(user site-settings page storage-file archive-entry) @@ -327,7 +329,7 @@ slug is updated based on `NEW-FILE-NAME'." "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))))) + (sxql:order-by (:desc :created-at))))) (defun create-archive-entry (title search-id slug pub-month pub-year thumbnail-slug thumbnail-file-type keywords) @@ -386,3 +388,19 @@ An example of how to use this function is as follows (remove back-slashes): (mito:delete-dao (mito:find-dao 'archive:archive-entry :id id))) ((not id) (mito:delete-dao (mito:find-dao 'archive:archive-entry :slug slug)))))) + +(defun get-newer-archive-entries (id amount) + "Returns `AMOUNT' of `ARCHIVE-ENTRY' objects relative to `ID' in database." + (with-connection (db) + (mito:select-dao 'archive:archive-entry + (sxql:where (:> :id id)) + (sxql:order-by :id) + (sxql:limit amount)))) + +(defun get-older-archive-entries (id amount) + "Returns `AMOUNT' of `ARCHIVE-ENTRY' objects relative to `ID' in database." + (with-connection (db) + (mito:select-dao 'archive:archive-entry + (sxql:where (:< :id id)) + (sxql:order-by (:desc :id)) + (sxql:limit amount))))