biff

jf 2024-11-09T03:58:08.969739Z

is there a way to remove an (optional) attribute from an existing document when doing :db/op :update with biff/submit-tx? setting the attribute to nil does not work and fails validation. I suppose one could possibly have malli accept nil.. but that doesnt seem so elegant; nor is it sustainable if one were to have many such attributes / cases where updates could involve removing attributes

2024-11-09T04:15:45.865079Z

you can set the value to :db/dissoc, see the transaction reference about 2/3 down: https://biffweb.com/docs/reference/transactions/

jf 2024-11-09T04:24:39.388349Z

I see. Thank you! Didnt know that. It just occurred to me that I could use / try :db/op :put as well; and it looks like it would work. If the attribute is not set, the document does not end up with that attribute. I assume this works as well?

2024-11-09T04:26:11.796309Z

yes, that approach would work too. if you have two simultaneous requests that both do a put operation on the same document though, one of the puts might get overwritten

2024-11-09T04:26:43.890269Z

:db/update ensures that concurrent writes don't get lost

jf 2024-11-09T04:29:27.801589Z

I see. Thank you!

👌 1