Fork me on GitHub
Dmitri Akatov08:08:37

Hi, I’m trying to understand the details of using [:db/lookup {:key "value"}] in a :db/op :update / :db/op :merge operation, when performing biff/submit-tx. It seems that a new document with {:xt/id {:key "value"}, :db/owned-by ...} is always created (whether the document with {:key "value"} existed or not). Are these documents with the {:db/owned-by …} key a pure internal biff thing that is used internally to e.g. help to (try to) look up the document(s) containing {:key "value"} ? Or am I (the developer) expected (/ permitted) to make use of these documents as well? If so, then what would be the use case?

Jacob O'Bryant15:08:29

They're just intended as an internal biff thing. it's basically a way to perform an upsert in XTDB without needing to register a transaction function first. you could use those docs in your own code to fetch documents by the given key faster, though I've personally always just used q like normal. in the future I might replace the :db/lookup thing with a transaction function. haven't decided yet.