Fork me on GitHub
#biff
<
2023-07-20
>
Epidiah Ravachol21:07:29

I have a sneaking suspicion that :xt/id is the one attribute I can't feed into biff/submit-tx's :db.op/upsert to check to see if the associated doc is already in the database.

Jacob O'Bryant21:07:40

hm, not sure if that does or doesn't work, but either way it shouldn't be necessary--you can just use :db/op :merge to get the same effect. :db.op/upsert is just there so you can update/insert docs on non-`:xt/id` keys, since XTDB already ensures that the :xt/id key is unique.

metal 2
Jacob O'Bryant21:07:55

(As an aside, migrating to/adding support for XTDB 2.0 will provide a good opportunity to rethink Biff's transaction format and try to sand off some of the unintuitive edges like this...)

Epidiah Ravachol22:07:01

Ah! :db/op :merge did the trick! Just when I was about to rethink my whole approach.

👌 2
🎅 2
Epidiah Ravachol15:07:58

I think I sussed out my mistake. When the :upsert didn't find the :xt/id I supplied, it created a new doc but instead of using the :xt/id I gave it, it rolled up a random uuid. Which makes sense and is exactly what the documentation told me what would happen. I just got so used to using :upsert with other attributes, I didn't think it through.

Jacob O'Bryant15:07:46

ah yes, that makes sense. in any case I think it'd be worthwhile to have a unified format for doing upsert, whether it's with xt/id or another key

👍 2