diff --git a/structlog-mode.el b/structlog-mode.el index 9102fe0..ec92b44 100644 --- a/structlog-mode.el +++ b/structlog-mode.el @@ -70,6 +70,9 @@ ":select [time event] :limit 100" "Default query for `structlog' command") +(defvar structlog-time-field 'time + "The structlog field designating the log timestamp") + (defun structlog--query-db (query) "Runs `query' against the database, returning a list of lists" (dolist (var '(structlog-db-username @@ -110,10 +113,14 @@ (let ((base (format "SELECT %s FROM %s" structlog-db-record-field structlog-db-table)) + (order-by (format "ORDER BY %s->'%s'" + structlog-db-record-field + structlog-time-field)) (limit (plist-get query :limit))) - (concat base + (concat base " " + order-by " " (when limit - (format " LIMIT %s" limit))))) + (format "LIMIT %s" limit))))) (defun structlog--make-list-entries () "Makes the tabulated-list-mode entries list for structlog"