From 4dd7f89cde9c95d43d601c4146ff24826cc28627 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 14 Dec 2023 13:19:15 +0200 Subject: Add gnosis-update --- gnosis.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index 16a8874..c38394e 100644 --- a/gnosis.el +++ b/gnosis.el @@ -84,6 +84,12 @@ Used to calcuate new interval for failed questions." "Insert VALUES to TABLE." (emacsql gnosis-db `[:insert :into ,table :values ,values])) +(cl-defun gnosis-update (table value where) + "Update records in TABLE with to new VALUE based on the given WHERE condition. +Example: + (gnosis-update 'notes '(= main \"NEW VALUE\") '(= id 12))" + (emacsql gnosis-db `[:update ,table :set ,value :where ,where])) + (defun gnosis-get (value table &optional restrictions) "Get VALUE from TABLE, optionally with where RESTRICTIONS." (caar (gnosis--select value table restrictions))) @@ -230,7 +236,7 @@ TAGS are used to organize questions." (error (message "No NOTES table to drop."))) (condition-case nil (gnosis--drop-table 'decks) - (error (message "No NOTES table to drop."))) + (error (message "No DECKS table to drop."))) (condition-case nil (gnosis--drop-table 'review) (error (message "No REVIEW table to drop."))) -- cgit v1.2.3