-
-
Save victorb/27f74557f8f452880b2c95126697f9f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Setup | |
(def crux-node #(deref instant-website.core/crux-node)) | |
(def email "test@example.com") | |
(def id (keyword (str "c" (random-hex 16)))) | |
(identity id) | |
(def pw (random-hex 8)) | |
(identity pw) | |
;; Add document | |
(crux/submit-tx (crux-node) [[:crux.tx/put {:crux.db/id id | |
:code/password pw | |
:code/email email}]]) | |
;; Make sure we can find it based on email + code | |
(crux/q | |
(crux/db (crux-node)) | |
{:find '[p1] | |
:where '[[p1 :code/email email] | |
[p1 :code/password code]] | |
:args [{'email email | |
'code pw}]}) | |
;; Save its ID | |
(def code-id (-> *1 first first)) | |
(identity code-id) | |
;; Running this form and then the find query still returns it | |
;; tx-id and tx-time increments when we run this though, so seems something | |
;; is happening | |
(crux/submit-tx (crux-node) [[:crux.tx/delete code-id]]) | |
;; But running this form makes the query not be able to find it | |
(crux/submit-tx (crux-node) [[:crux.tx/evict code-id]]) | |
;; Here, after running crux.tx/delete we should no longer find it, but currently | |
;; only goes away if we run the crux.tx/evict | |
(crux/q | |
(crux/db (crux-node)) | |
{:find '[p1] | |
:where '[[p1 :code/email email] | |
[p1 :code/password code]] | |
:args [{'email email | |
'code pw}]})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment