Fork me on GitHub
#datomic
<
2020-05-04
>
mruzekw02:05:06

Does Datomic Ions at all handle deployment of a static frontend SPA?

joshkh11:05:21

how do you mean? do you want Ions to act as a web server and serve the static frontend from somewhere like S3?

Joe Lane13:05:56

@U1RCQD0UE Put that static frontend spa in an S3 bucket which is cached by cloudfront. Then set up a codebuild/codepipeline job any time it changes and be sure to do a cloudfront cache invalidation on every successful build.

mruzekw17:05:10

Thanks Josh and Joe. I was thinking the S3 + Cloudfront route.

mruzekw17:05:37

I was wondering if I had to add something extra like Serverless Framework to deploy an SPA frontend

mruzekw17:05:44

Sounds like I do

Joe Lane18:05:43

No need for a framework, you can compile your assets and s3 cp ./my-project

joshkh11:05:22

is there a way to query for the inclusion of a value anywhere in a tuple attribute? something like:

(d/q '{:find  [?social-connection]
       :in    [$ ?person]
       :where [
               [?social-connection :friendship/from+to ?person]
               ]}
     db "Bob") 

joshkh11:05:16

i guess i could wrote a more sophisticated query to identify the attributes in the tuple attribute and check each one

favila12:05:14

Destructure person

favila12:05:47

Note this is going to scan every friendship/from+to value

joshkh13:05:18

thanks, favila. what do you mean by destructure person?

favila13:05:01

[?social-connection :friendship/from+to ?people][(untuple ?people) [?person ...]]

Joe Lane13:05:28

Interesting, I never knew [?person ...] syntax worked on tuples...

favila13:05:57

(psst, tuple is vector and untuple is identity)

joshkh13:05:45

yeah, that's brilliant @U09R86PA4. thanks for pointing that out -- it's exactly what i needed.

favila13:05:18

note the caveat, this is a full scan of that attr’s values

favila13:05:35

if you have a non-tuple card-many attr you can match on exactly, that is better

favila13:05:49

(or many such attrs)

joshkh13:05:56

definitely. as my business entities and tuple constraints grow, i find now and again that when an entity is retracted, it produces a tuple somewhere else with a nil value (metaphorically). then, retracting another entity that shared common values in the remainder of the tuple fails due to conflicting datoms.

joshkh13:05:17

two existing tuple entities: [friend-a friend-c] [friend-b friend-c] retract friend-a: [nil friend-c] [friend-b friend-c] retract friend-b and fail: [nil friend-c] [nil friend-c]

joshkh13:05:59

is working around the issue something you've experienced? i've toyed with inbound component references (but this feels dirty and difficult to manage), or transactor functions to look for tuples, or an API to handle retracting known related tuples.

favila13:05:32

yes, unique composite attrs with refs definitely have this problem

favila13:05:46

we’re just more careful about retractions

favila13:05:25

if the index exists just to ensure uniqueness, consider enforcing uniqueness on write with a :db/ensure function

favila13:05:07

but a “cascading delete” flag on a tuple attr would sure be nice

joshkh13:05:32

absolutely, i always think of it as a "reverse component reference"

favila13:05:02

I don’t think this can be done with a tx fn because you need to know the final value of the tuple after all primitive datom operations are applied

joshkh13:05:16

also we're in the same place: use caution. but that comes with a lot of insider knowledge for new engineers to pick up before they start working with the data, because they have to know how all existing tuples connect the data model.

joshkh13:05:44

ah. tx fns were next on my list to explore. you saved me some time 😉

Brian14:05:38

Is there any way to load a database backup from disk into an in-memory datomic database? If not, what is the standard for datomic tests that reach a database?

favila14:05:53

generally test fixtures will create an in-memory database and get it into the state being tested

favila14:05:24

if you want to start from a database you have already, you can use it as a dev db; but make sure you don’t write to it

favila14:05:44

datomock can help

Brian14:05:28

Okay thank you!

Sam DeSota17:05:41

Created a little script for deploying ions without the ceremony in case any one one here could use it: https://gist.github.com/mrapogee/251a6b279f1224b90698676f842aaa74

👍 8
john-shaffer00:05:59

Nice. There is a case macro that can simplify your cond.