summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-14 13:19:15 +0200
committerThanos Apollo <[email protected]>2023-12-14 13:19:45 +0200
commit4dd7f89cde9c95d43d601c4146ff24826cc28627 (patch)
treee2167ddbf6927aa4d23463f4239876202bbe31d6
parent801cda946148a06953930ca6ce0c62cadebfa5c7 (diff)
Add gnosis-update
-rw-r--r--gnosis.el8
1 files changed, 7 insertions, 1 deletions
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.")))