Closed samedhi closed 4 years ago
My curent thinking is to write a macro of this form
(transaction!
[symbol1 <ref1>
symbol2 <ref2>
symbolN <refN>] ;; documents to read
(write! ...)
(merge! ...)
(delete! ...))
Where the return value is the return (or error) of the transaction.
What if I need to read a document, then based on something in the document, read another document. Could it look like this?
(transaction!
[symbol1 <ref1>]
(transaction!
[symbol2 (:id-to-read symbol1)]
(write! (:id symbol2) (cross-document-fx symbol1 symbol2))))
OR
(transaction!
[symbol1 <ref1>
symbol2 (:id-to-read symbol1)]
(write! (:id symbol2) (cross-document-fx symbol1 symbol2)))
I think the later is better, but it implies that the reads are being done sequentially.
Firebase (Firestore) has the ability to do transactional writes. Transactions are often necessary to correctly write data. Firebase transactions on the web seem to be in the form of writing a js function that reads 0 or more entities, and then writes 0 or more entities. Can we get this working on firemore within cljs as well?
https://firebase.google.com/docs/firestore/manage-data/transactions