fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
roklenarcic 2020-08-30T12:01:19.139100Z

How would you describe an attribute in RAD which is represented by a composite of 2 columns in the database?

roklenarcic 2020-08-30T15:18:31.141300Z

or even a normal one to many: for instance there’s a user table with PK id , and there’s a table user-authority where there’s no PK, just user-id which links the first table and some data… I don’t know what to specify as identity attribute for user-authority

Michael W 2020-08-30T15:31:16.142500Z

I think each "table" should have an unique id, I use uuids myself just like the demo app.

Michael W 2020-08-30T15:33:25.143700Z

(defattr id :bookmark/id :uuid
  {ao/identity? true
   ao/schema    :production})

roklenarcic 2020-08-30T16:16:08.150Z

Many existing databases don’t have an ID column in every table and if you ask any SQL purist, they really shouldn’t have an ID column if existing columns naturally present a key. Otherwise you are doubling your indexes e.g. you have index on ID, then a unique index on service, email columns, since they are a natural PK in the table in question… the whole discussion is moot because I have to use existing data sources and as such this decision is not mine to make. Btw in many-to-many linking tables, do you have a special ID for that too e.g. id, foreign_id_1, foreign_id 2 ?

Michael W 2020-08-30T16:38:57.151300Z

No afaik just making it a ref is enough, it is not like sql in that it creates a graph and traverses it, you do not need to specify the foreign key because the ref uses the entity id to join them.

Michael W 2020-08-30T16:39:53.152Z

["1" :user/name "mike"] ["1" :user/email "<mailto:mike@mike.com|mike@mike.com>"]

Michael W 2020-08-30T16:40:09.152300Z

So both are tied by the same entity id

Michael W 2020-08-30T16:41:01.152700Z

This helped me understand what was happening: https://docs.datomic.com/on-prem/query.html

Michael W 2020-08-30T16:49:38.153700Z

Everything is flattened to entity-attribute-value-time, so "tables" don't exist, and refs are just an attribute join on an entity id.

roklenarcic 2020-08-30T17:05:36.154500Z

so when working with a legacy DB I guess the answer is to make tons and tons of custom resolvers that present existing data in this way…

Michael W 2020-08-30T17:06:50.155700Z

That's pretty much how you have to do it, in terms of foreign keys #pathom might be better to answer questions on specifics, I'm still pretty new to all this stuff, but I think it's pathom that requires an ident to be set to normalize the data.

Michael W 2020-08-30T17:08:39.156500Z

I didn't use SQL but tied to a rest api and it took a significant number of resolvers to get everything into the format fulcro/pathom wanted.

Michael W 2020-08-30T17:11:33.158100Z

For the rest api I only needed 1 resolver per ident to get it working, but had to create a bunch more resolvers to make things more efficient, since with just 1 resolver per ident it would query many times to get a single item that had what in SQL would be joins.

roklenarcic 2020-08-30T17:17:26.159800Z

On the topic of joins… I tried to make attribute with ao/pc-resolve use batching by adding `

::pc/transform pc/transform-batch-resolver
to the attribute map, but the input I get is not sequential… are these keys supported on attributes?

Michael W 2020-08-30T17:18:54.160600Z

Yeah that's a pathom question, I don't know enough about it to answer, maybe somebody else will know. The #pathom channel is usually pretty good.