Add order-by clause
This commit is contained in:
parent
e86983d522
commit
5b8b758c1a
@ -70,6 +70,9 @@
|
|||||||
":select [time event] :limit 100"
|
":select [time event] :limit 100"
|
||||||
"Default query for `structlog' command")
|
"Default query for `structlog' command")
|
||||||
|
|
||||||
|
(defvar structlog-time-field 'time
|
||||||
|
"The structlog field designating the log timestamp")
|
||||||
|
|
||||||
(defun structlog--query-db (query)
|
(defun structlog--query-db (query)
|
||||||
"Runs `query' against the database, returning a list of lists"
|
"Runs `query' against the database, returning a list of lists"
|
||||||
(dolist (var '(structlog-db-username
|
(dolist (var '(structlog-db-username
|
||||||
@ -110,8 +113,12 @@
|
|||||||
(let ((base (format "SELECT %s FROM %s"
|
(let ((base (format "SELECT %s FROM %s"
|
||||||
structlog-db-record-field
|
structlog-db-record-field
|
||||||
structlog-db-table))
|
structlog-db-table))
|
||||||
|
(order-by (format "ORDER BY %s->'%s'"
|
||||||
|
structlog-db-record-field
|
||||||
|
structlog-time-field))
|
||||||
(limit (plist-get query :limit)))
|
(limit (plist-get query :limit)))
|
||||||
(concat base
|
(concat base " "
|
||||||
|
order-by " "
|
||||||
(when limit
|
(when limit
|
||||||
(format "LIMIT %s" limit)))))
|
(format "LIMIT %s" limit)))))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user