What is the idomatic way to do incremental update in XTQL? In SQL you can do update docs set foo = 'bar' where _id = 1; and it will only update foo and leave the rest of the data intact. However in XTQL [:put-docs :docs {:xt/id 1, :foo 'bar'}] will set the value of foo but wipe out all other data related to :xt/id 1.
noted - thanks folks 🙏
Since it is document-based, you have to fetch the whole document, update that one field, and write a new version of the whole document back. In XT2, that is what that SQL statement does behind the scenes, even tho' it looks like it "will only update foo and the rest of the data intact".
In XT1, you could do that sort of thing with a transaction fn. I haven't really kept up with XTQL since I'd prefer to use SQL with XT2.
According to the XTQL docs, "update" is https://docs.xtdb.com/reference/main/xtql/txs.html#_update:insert-into with a query???
(Looks like :insert-into is duplicated into the :update section so that must be wrong)
Ah, here we are: https://docs.xtdb.com/tutorials/introducing-xtql.html#_update
Aha! Thank you!
The incorrect documentation really threw me 😞. Hopefully that will be fixed!