untangled

NEW CHANNEL: #fulcro
sova-soars-the-sora 2017-01-13T01:09:31.002042Z

Could someone explain how the pull syntax works with the ellipsis ( ... ) on this line?

adambros 2017-01-13T01:12:42.002045Z

@sova that’s just saying it’ll pull a collection iirc it should return [name1 name2 …] instead of something weird like [[name1] [name2]]

sova-soars-the-sora 2017-01-13T01:13:59.002046Z

Oh cool. Ah that makes some sense. Man, I just found Datascript... super stoked to have a client-side "db"

adambros 2017-01-13T01:15:43.002047Z

yeah at navis/untangled we’ve tried datascript but found it slow and unnecessary for the client db when simple map lookups work fine and fast but maybe @tony.kay might have more to say on that

sova-soars-the-sora 2017-01-13T01:16:54.002048Z

when you say "map lookups" ... data is stored on the client-side but in a different way?

tony.kay 2017-01-13T01:23:37.002049Z

@sova why do you care about a client-side datomic database (e.g. Datascript)? There are good use-cases...I'm just wondering what yours is

sova-soars-the-sora 2017-01-13T01:25:36.002051Z

Thinking forward to mobile versions, I want users to be able to browse lots (~100s) of articles without the need to constantly ask the server. And it will probably help me in learning read/mutate better, since I know Datomic well, but am still having trouble wrapping my mind around how it interops with omnext

tony.kay 2017-01-13T01:26:10.002052Z

so, that would not be a use-case I'd involve datascript for

sova-soars-the-sora 2017-01-13T01:26:23.002053Z

Really the main benefit is offline enjoyment of resources.. perhaps there are alternatives

tony.kay 2017-01-13T01:26:35.002054Z

you're talking format, not the ability to offline

tony.kay 2017-01-13T01:26:46.002055Z

Datascript stores data...so does a map

tony.kay 2017-01-13T01:26:57.002056Z

so does a vector

tony.kay 2017-01-13T01:27:30.002057Z

Datascript gives you a high-end parser of Datalog to do complex data operations. Using it for holding a collection is like putting in a thumbtack with a 50lb sledgehammer

sova-soars-the-sora 2017-01-13T01:28:17.002059Z

Haha, well that's an illustrative way to put it. Do you think it'll slow down things considerably to "bog down the browser" with a Datascript instance?

tony.kay 2017-01-13T01:28:50.002060Z

So, it will increase app load time (bigger js footprint), but not terribly. The thing is, how do you plan to use it?

tony.kay 2017-01-13T01:29:21.002061Z

If using Untangled, you're going to...what...write a mutation that does a datascript query to copy data from datascript into your UI?

tony.kay 2017-01-13T01:30:06.002062Z

If using Om Next, you write parser emitters for the query that would query datascript, but that is going to make your UI slower, because running a query is a heck of a lot slower than looking things up in a map(what Untangled does)

tony.kay 2017-01-13T01:30:59.002063Z

and how do you populate your Datascript database? With a network request. Well, Untangled already gives you that ability, and can pull the result into it's app database (and cache it there).

tony.kay 2017-01-13T01:31:20.002064Z

client local storage could be used to cache either for offline access

tony.kay 2017-01-13T01:32:20.002066Z

so, it has a cool factor, but from my perspective you've done nothing but added incidental complexity

tony.kay 2017-01-13T01:33:56.002067Z

For completeness: a good use-case for datascript is you want to download a bunch of data for analysis that will use the user's CPU. Put it in datascript and write the data analysis in cljs, and then you actually want datalog support on the client.

tony.kay 2017-01-13T01:34:14.002068Z

kind of a trade network overhead for CPU

sova-soars-the-sora 2017-01-13T01:34:42.002069Z

It's a bit of a tangential approach, but I'm thinking of working in steps. I don't mind the slow-down because the javascript app object already takes a few seconds to be mounted. Yeah, it requires a network request. To my naive beginners' eyes it seems cleaner than playing directly with an app-state atom on the client. I think it'll make it easier to reason about my app (long) into the future, though.

tony.kay 2017-01-13T01:35:12.002070Z

welp, feel free. The worst that can happen is learning 🙂

sova-soars-the-sora 2017-01-13T01:36:24.002072Z

Correct me if i'm not, but there's basically the Datomic-friendly read (for :remote true) and then there's the local client-side atom read ... I just like the idea of the code reuse, but it might verywellbe overkilll.

sova-soars-the-sora 2017-01-13T01:37:05.002073Z

I see what you mean for a good use-case. There really isnot a lot of computation in my application. Just a lot of text sharing between server and client.

tony.kay 2017-01-13T01:37:11.002074Z

In Untangled, you don't have to write any read on the client. ever.

sova-soars-the-sora 2017-01-13T01:37:37.002076Z

Okay I must have missed that, since that is news to me.

tony.kay 2017-01-13T01:37:42.002077Z

the remote thing sends the read over the network

tony.kay 2017-01-13T01:38:11.002078Z

the response to the client read from datomic is automatically merged into the app database. There is no work for you to do.

tony.kay 2017-01-13T01:38:18.002079Z

In stock Om next, there is a ton to do (network pipeline, merge augmentation, satisfying client read, etc.)

tony.kay 2017-01-13T01:38:46.002081Z

Untangled exists so you don't have to do all that

sova-soars-the-sora 2017-01-13T01:38:50.002082Z

Right! So much haha. But you're saying that that's all flattened out in untangled...

tony.kay 2017-01-13T01:39:08.002083Z

no, we use the default app state atom format of Om Next (graph db in a map)

tony.kay 2017-01-13T01:39:13.002084Z

normalized

tony.kay 2017-01-13T01:39:16.002085Z

not flattened

tony.kay 2017-01-13T01:39:24.002086Z

(well, it is a form of flattening)

tony.kay 2017-01-13T01:40:29.002087Z

Have you followed along on the dev guide tutorials and written a full-stack app yet?

sova-soars-the-sora 2017-01-13T01:40:43.002088Z

Datascript appeals to me because I never ever want to touch db->tree.

tony.kay 2017-01-13T01:41:16.002089Z

1. db->tree is cool. Don't knock it 😉 2. Untangled calls db->tree for you. So you don't have to

tony.kay 2017-01-13T01:41:42.002090Z

what you do have to do is make sure your app db has what you're asking for

sova-soars-the-sora 2017-01-13T01:41:44.002091Z

I'm working on an app, but starting from scratch (is good for the learns.) It just seems like an unbridge-able chasm at the moment to negotiate between the app-state atom and my datomic store

tony.kay 2017-01-13T01:42:08.002092Z

@sova then you have not learned the primitives properly yet.

sova-soars-the-sora 2017-01-13T01:42:16.002093Z

Such is my suspicion, haha.

tony.kay 2017-01-13T01:42:22.002094Z

not only is it bridgeable, it is nearly trivial 😉

tony.kay 2017-01-13T01:42:39.002095Z

thus my opinion that adding in Datascript takes you backwards

tony.kay 2017-01-13T01:42:43.002096Z

it makes it harder

sova-soars-the-sora 2017-01-13T01:42:55.002097Z

Man once I get this working I am going to write some awesome articles about doing all this stuff (to help the documentation efforts of all these wonderful things)

tony.kay 2017-01-13T01:43:05.002098Z

Did you find the YouTube getting started videos?

tony.kay 2017-01-13T01:43:17.002099Z

There are so many resources to walk you through this 🙂

sova-soars-the-sora 2017-01-13T01:43:34.002100Z

Yeah? Okay, that's good to keep in mind, that datascript would kinda be a move in the opposite direction.

tony.kay 2017-01-13T01:43:41.002101Z

devguide, ref manual, videos, cookbook

sova-soars-the-sora 2017-01-13T01:44:19.002102Z

I have played with the devcards a bit, they are very helpful.

sova-soars-the-sora 2017-01-13T01:44:47.002103Z

It's a little tough to find out exactly what knowledge I need to make everything tie together. Currently seems like a Rubiks' Cube

sova-soars-the-sora 2017-01-13T01:44:55.002104Z

Messy messy messy until it all comes together at a point

tony.kay 2017-01-13T01:45:13.002105Z

https://www.youtube.com/watch?v=t49JYB27fv8

tony.kay 2017-01-13T01:45:50.002107Z

there's a playlist of these, but this one demos doing server integration. Imagine datomic satisfying the server query (1-2 lines of code)...the rest is the same

sova-soars-the-sora 2017-01-13T01:46:45.002108Z

Hmm. So there are just a few magic lines to add to ask Datomic for all the goods... Is that where (db->tree) comes into play? Translating the graph-DB (datomic) into the app-state atom?

tony.kay 2017-01-13T01:47:05.002109Z

no, the pull query of Datomic is the magic

sova-soars-the-sora 2017-01-13T01:47:10.002110Z

thank you for the link, by the way.

tony.kay 2017-01-13T01:47:11.002111Z

no db->tree ever

tony.kay 2017-01-13T01:47:28.002112Z

Om query syntax matches Datomic pull syntax

tony.kay 2017-01-13T01:47:39.002113Z

you basically just pass the Om query straight to Datomic

tony.kay 2017-01-13T01:47:49.002114Z

and return the result it gives back

sova-soars-the-sora 2017-01-13T01:48:01.002115Z

Okay. The pull is the magic. So there's a generic query line that talks to the DB and the pull syntax can get any biscuit I need based on color, shape, wheat, etc... (to use bread as an example)

tony.kay 2017-01-13T01:48:25.002116Z

http://docs.datomic.com/pull.html

tony.kay 2017-01-13T01:49:14.002117Z

http://blog.datomic.com/2014/10/datomic-pull.html

tony.kay 2017-01-13T01:49:49.002119Z

you see it looks just like Om queries...and returns data in the map structure you need

sova-soars-the-sora 2017-01-13T01:50:59.002120Z

Ah yes. Okay. Still some fuzziness in my head about how it all fits together, but that makes sense. Om.next query is essentially a datomic query and what comes back is that beautiful map...

tony.kay 2017-01-13T01:52:11.002121Z

yep. So typically what you do on the client is send a query from some sub-portion of your UI (say you want to pull the items in a todo list)...you send the query for Item, along with a parameter (the entity of the list)

tony.kay 2017-01-13T01:52:31.002122Z

The server does a pull query anchored at that entity, which gives you back the items

tony.kay 2017-01-13T01:52:44.002123Z

Untangled will automtically merge those items into your app db.

tony.kay 2017-01-13T01:53:22.002124Z

Then, you can (on the client) add in a post-mutation that creates a list of idents of those items, and places them in the place you want to show them. Possibly is sorts them. Possibly it filters them. etc. etc.

tony.kay 2017-01-13T01:53:32.002125Z

but getting them into your db is effortless

tony.kay 2017-01-13T01:54:48.002126Z

adding a bit of linkage so your UI sees what you want it to see is just a slight bit of graph joining...which is typically as simple as (swap! state assoc-in [:todo-list/by-id 42 :items] [[:item/by-id 1] [:item/by-id 2] ...])

tony.kay 2017-01-13T01:55:22.002128Z

where the list of idents can even be derived from the table

tony.kay 2017-01-13T01:57:04.002129Z

e.g. (mapv (fn [i] [:item/by-id (:db/id i)]) (vals (get @state :item/by-id)))

tony.kay 2017-01-13T01:58:02.002131Z

but understanding what I just said above means you need to understand, very clearly, the graph db format...which really is quite simple: top-level tables as maps, and idents for pointers

tony.kay 2017-01-13T01:58:44.002132Z

good luck...I'm going to get some food. I'd really recommend watching the videos on YouTube if you have not. I walk through quite a bit of this in detail.

sova-soars-the-sora 2017-01-13T02:37:36.002133Z

Thanks @tony.kay I appreciate your help as always.

sova-soars-the-sora 2017-01-13T02:39:07.002134Z

I don't understand what you mean when you say "along with a parameter (the entity of the list)" ... My datomic store has many individual elements (i refer to them as blurbs) and each one has a :blurb/title, :blurb/content, :blurb/author ... i do want to bring them to the clientside but I have no ":blurb/list" element in datomic, is that something that exists (only) in the client side atom

sova-soars-the-sora 2017-01-13T02:59:39.002135Z

䀀

sova-soars-the-sora 2017-01-13T03:01:21.002136Z

Thanks for that video! one thing that became clear was that :whatever/by-property is actually an Om-next special syntax that messes wth the atom state :property .... i was really curious about that. like by-id (and how it knew)

tony.kay 2017-01-13T16:14:24.002141Z

@sova Nothing special about it. It is a name to remind the person coding that the table has keys that are IDs. The ident function (that you write) makes these up. If you index by id, then usually you'll name the table /by-id.

tony.kay 2017-01-13T16:15:00.002142Z

If you have no ownership of blurbs, then you'd just query for them all and send them down, and yes, then your client code would "make up" a :blurb-list top-level key

tony.kay 2017-01-13T16:15:16.002143Z

usually you have some kind of ownership...at least to the logged-in user, or a topic, etc etc

tony.kay 2017-01-13T16:15:21.002144Z

which is what I meant

michaeldrogalis 2017-01-13T18:02:56.002149Z

Is it possible to access the database connection inside untangled-datomic’s migrations without using migrate-with?

sova-soars-the-sora 2017-01-13T18:50:30.002150Z

I'm really thankful for Untangled and all the resources you guys have contributed and offered to the community. Really awesome. Hope I can contribute something back eventually.