Fork me on GitHub
#datascript
<
2021-09-29
>
mokr18:09:08

Hi, can anyone here confirm that re-posh (Posh) does not pick up on DB changes when the part of the query that changes is a reverse reference lookup (like :_selected)? UI reloads triggered by e.g. shadow-cljs confirms that my code actually works, so the issue is that re-posh does not automatically refresh my UI component that relies on such a reverse lookup. I attempted to work around it by adding a :db/tupleAttrs with the reverse lookup, but it ends up as nil so I guess Datascript doesn’t support that. Any ideas before I rewrite to something less elegant? The general idea here is that I have a UI listing of Datascript entities and want to highlight the one that is currently pointed at by :selected ref on a “special” focus entity. UPDATE: Abandoned the concept of referencing the selected entity and instead resorted to move a :selected? attribute around as a token. Still interested in the general feasibility of using reverse references in re-posh queries if anyone has some insight.

metasoarous20:09:12

It should be possible to fix this in Posh; I'd suggest raising an issue here: https://github.com/denistakeda/posh/issues

metasoarous20:09:52

There were some known issues along these lines on the original mpdairy fork, and my sense was that denistakeda had fixed up a few of them, but there may be more.

metasoarous20:09:24

Can confirm that :db/tupleAttrs is not supported yet, though I think tonsky has considered doing this. I can say that #datahike does have this, and there was at least at one point a hope that posh could be agnostic as to the backend store (even running on datomic server side as an option), but I think it may have still involved some "glue code" to get this sort of thing to work, and I'm not sure what denistakeda's plans with all that are.

metasoarous21:09:46

PS It is also possible to specify a manual update pattern to force the query to update on a broader set of fact patterns (even on every tx), so that's one escape hatch you could use for now.

mokr07:09:36

Thanks for all the input @U05100J3V, I need to research that manual update pattern for future “emergencies”.

👍 1