Fork me on GitHub
#fulcro
<
2020-09-15
>
tony.kay00:09:22

I do not understand your intention. ao-identity? is a HINT to the RAD plugins that the given attribute can be used to find rows/entities, etc. It lets db plugs do things like generate indexes on that column, etc. The ao/identities is says what ID you can use to FIND the the attribute on which it is declared. So, you’re saying :content/id is an attribute that can be found IF you know either a :category/id or an :element/id. This is how the RAD plugins do things like figure out “entity” or “table” groupings (if supported in the given db), but it is also used to generate resolvers (if you have :category/id, then I can given you a :content/id).

tony.kay00:09:24

in terms of “creation”. RAD Forms only know about the primary ID of an entity. The fact that there is an extra ID is up to you to deal with. I’d recommend looking at save middleware. You could examine incoming save deltas and augment them.

tony.kay00:09:55

So, your RAD form probably would not even mention the alt ID? Not sure what all you’re trying to do, but those are my initial thoughts

xceno09:09:10

I did mention it, but yes I'm sorry, my example wasn't very good. I've read all the docs and docstrings and watched your videos, so I think I roughly understand what's going on. I was just thinking way to complicated yesterday. Basically my intention is to connect all kinds of entities via an edge entity that has lots of metadata like so:

{:edge/id ...
  :edge/origin :ref ;; to whatever entity
  :edge/targets :ref ;; to multiply entities of any "type"
  :edge... ;; lots of other stuff
}
But now I'd need multiple keywords (all my various entity ids) for the ao/target on my origin and targets attributes, which obviously doesn't work. That's where my idea for a global :content/id attribute came from, that I slap on every entity. Anyway, I'll give the save-middlerware a shot. Thank you

xceno11:09:30

> So, you’re saying `:content/id` is an attribute that can be found IF you know either a `:category/id` or an `:element/id`. Oh I think that's my problem, I wanted it the other way around. Thanks again. I shouldn't code after midnight

tony.kay15:09:58

No, don’t do any of that content/id mess. What you want is to add all of your ID keys to identities on :edge/origin, etc. That is then in the intended design

tony.kay15:09:11

oh, no, I see: to-many edges need many edge facts

tony.kay15:09:07

If you’re using UUIDs, then a natural key for an edge is source-id, target-id

xceno15:09:55

Well, you're right it turned out to be a mess indeed! I think simplifying my edges to only have one target would help here

tony.kay15:09:39

not sure if leveraging that is easy for your application logic, but then you don’t need edges to have an id of their own…depends on if you want to reify the edge in a query of the graph (flatten it into the child, for example) or if you’re just trying to store it for separate analysis

xceno15:09:10

Well, what I'm trying to do is modeling edges that act as constraints. So I can build a queries that walk a graph, but stop on certain edges that are forbidden. Or I walk a graph further down when I come across and edge that marks another entity as required. I designed this schema for datomic before starting this project, and I'm new to graph dbs and datomic, so I'm sorry if some of my statements seem confusing. I'm trying to figure things out as I go. But I'll give both your advices a try, I'm going to throw away my content/id thing and simplify my target attribute to a to-one ref. But thinking about your second point - flattening the edges into my entities might be a bit more work initially but should simplify it even more. I think I can figure it out from here. Thanks for your time, I really appreciate it! I'll build an exmple project for everyone to check it out once I solve this

Mr. Savy03:09:42

does it matter if I use a function for the :query as compared to just a vector? the book suggests saving them for unions from what I've seen.

tony.kay05:09:18

Using lambda notation disables the macro's error checking, and disables other things like magic initial state. I never use fn except when error checking is mistaken

👍 3
tony.kay20:09:46

Fulcro 3.3.0 now has better support for hot code reload when you’re using dynamic queries. This eliminates most needs to hard reload (browser refresh) the app. See http://book.fulcrologic.com/#_hot_code_reload_and_dynamic_queries

👏 15
tony.kay20:09:42

TL;DR: Upgrade to 3.3.0, and add this to your refresh function that shadow-cljs calls:

(comp/refresh-dynamic-queries! app)

tony.kay20:09:04

and enjoy fewer presses of CMD-R in chrome 🙂

tony.kay22:09:52

I’m going to push 3.3.1…I accidentally left a debug logging message in 3.0.0 😕

cjmurphy22:09:38

Fulcro RAD now has another possibility for storage: Key Value stores (in general). The repository is setup as another RAD Demo, just to demonstrate it all working. Please take a look: https://github.com/fulcrologic/fulcro-rad-kvstore

👍 27
tony.kay00:09:09

I’d like to point out that this new kvstore gives us a lot of new possibilities. It is using Konserve underneath, so the redis “plugin” for it is almost no code. Any of the adapters it has should work, I think. https://github.com/replikativ/konserve#external-backends I use Redis for session storage, and this now makes it easy to use RAD to quickly build out admin screens that can deal with live session data. Pretty darn cool.

az22:09:38

Any thoughts on why after every other key stroke, if I submit this, stashed-text is null in submit-form. Also on this note, for local component state, should I be using an atom or the react local state mechanism? Thanks.

tony.kay22:09:38

you’re not using update-state! correctly. If takes a function that gives you the old state, and you return new state…

tony.kay22:09:53

so you’re walking into your data structure and using the nested data as the new data, which will only work once

az22:09:25

Thank you I see!

tony.kay00:09:09

I’d like to point out that this new kvstore gives us a lot of new possibilities. It is using Konserve underneath, so the redis “plugin” for it is almost no code. Any of the adapters it has should work, I think. https://github.com/replikativ/konserve#external-backends I use Redis for session storage, and this now makes it easy to use RAD to quickly build out admin screens that can deal with live session data. Pretty darn cool.