Fork me on GitHub
#datomic
<
2017-06-23
>
danielcompton03:06:33

We're looking at Datomic data modelling and have seen a bunch of different libraries that provide abstractions over raw Datomic schema syntax. Some are light syntax, some are full-on ORMs. This is our first Datomic project, so I'm leaning towards minimal layers on top of Datomic if any, but wondered what people with experience would recommend? https://github.com/vvvvalvalval/datofu https://github.com/Provisdom/spectomic https://github.com/nrakochy/schmad https://github.com/vvvvalvalval/onodrim

akjetma04:06:23

This might be heavier than what you’re looking for, but zcaudate’s Spirit library seems really cool, thought i’d throw it up for consideration: http://docs.caudate.me/spirit/spirit-datomic.html

robert-stuttaford05:06:17

@danielcompton i highly recommend you start with the Datomic api directly. those libs, as good as they are, were oriented towards whatever those people were building. using one of them shades your thinking with that direction, and also teaches you that API instead of Datomic’s own. after nearly 5 years with it, and several attempts to use abstractions like this, i can tell you that the Datomic API is incredibly well designed 🙂

robert-stuttaford05:06:11

recent changes in Datomic also removes the helper data that the transactor used to need when declaring schema, so it really is nice, clean, declarative data now. like Rich says, don’t be scared of a little typing, and you’ll be fine!

danielcompton05:06:53

Thanks, that's what I suspected but good to hear it confirmed

danielcompton05:06:12

as that seems to cut down on the verbosity of the schemas

robert-stuttaford06:06:23

quite honestly, schema verbosity is a non-issue. it lives in your database. the code that puts it there is transitory. once done, you should be looking at your database for schema, not your code

val_waeselynck12:06:47

robert-stuttaford: I have a different experience, verbosity has been an issue for us, and writing the schema in code has its benefits. On contrary, I've found it viable to think of the database as "catching up" with the code, not the other way around. My point being it's not obvious there's one right way to think about this 🙂

uwo12:06:24

our team generates schema from code and, in my opinion, it has led to a number of pitfalls. (Our shortcomings could simply be attributed to us as a team of developers of course) I’ve noticed that we’ve ignored a lot of best practices when our model code doesn’t bend the right direction, like we’ll end up changing the semantics of attributes, essentially “reusing” a name. Recently our team started thinking about migrations as rollback or roll forward, which just completely blows my mind. I think if they weren’t looking at code that they edit in place, they’d be forced to have the right mental model.

val_waeselynck13:06:01

you do need the discipline to avoid breaking changes with the "code as the source of truth" approach, but I think it's not too contraining with Datomic.

uwo13:06:45

yeah, I think our issues are probably lack of discipline or injured sensibilities

akjetma17:06:45

how do you guys handle synchronizing schema across local/staging/production environments?

val_waeselynck20:07:35

@U0518FWJV periodic backups from production, plus forking locally

robert-stuttaford06:06:45

this becomes very apparent when you have multiple apps on a single database 🙂

robert-stuttaford06:06:09

@danielcompton you may find the Datomic console or https://github.com/Cognician/datomic-doc#search useful for inspecting your database over time

danielcompton06:06:04

Nice I just saw that

kwladyka06:06:57

What are downsides of embedded Datomic Datalog (local storage) vs SQL storage or others? What are differences?

robert-stuttaford06:06:29

for what environment, @kwladyka ? dev? production?

robert-stuttaford06:06:29

so, dev + transactor-local are really not for production settings: they co-locate the data with the transactor process. this loses you some of the benefits of Datomic’s deconstructed design; to scale either, you need to scale both — but having said that, it’s really not scalable for storage.

robert-stuttaford06:06:23

but, having said all that, i know some folks use it anyway. it all depends what your needs are 🙂

kwladyka06:06:16

now i mainly still consider datomic free vs postgresql, i want do things like for example generate labels for label printer for orders in e-store etc. These are too small things to pay high price for datomic at that moment.

robert-stuttaford06:06:49

why not start with free, and switch when you feel it’s time to?

kwladyka06:06:09

Maybe, just still thinking about it.

kwladyka06:06:38

But the main problem is it wouldn’t be SaaS probably, so each client has to have own database and it makes it very costly.

robert-stuttaford06:06:22

ah, you’re speaking of distribution. you’ll want to check the EULA for that.

kwladyka06:06:32

hmm is it work in different way than normally?

robert-stuttaford06:06:01

@marshall will be able to tell you

danielcompton09:06:30

I think datomic free is fine for distribution

karol.adamiec09:06:19

https://my.datomic.com/downloads/free “Datomic Free is suitable for open-source projects requiring distribution, but is limited to 2 simultaneous peers and transactor-local storage only.”

val_waeselynck12:06:25

@danielcompton @robert-stuttaford I'm biased as the author of course, but with Datofu I've really attempted to be close to the metal without imposing any opinions or additional concept - the only things Datofu attempts to achieve regarding schema declaration are readability and concision without losing any expressive power. Having said that, I also recommend you start without any library and consider adding it when you feel things are becoming tedious.

val_waeselynck12:06:27

@danielcompton Also, please don't use Onodrim yet, it's not even alpha-ready - apologies if I miscommunicated that in the README. I may have something usable by the end of this Summer.

naomarik12:06:12

@val_waeselynck starting bare was going to be my approach. Your recent blog post was helpful in redirecting my attention to Datomic and the new less restrictive licensing options makes it very appealing to use now. It would be cool to to see some information on why you would want to use something on top of bare Datomic and the problems they solve so newcomers have something to reference when they start hitting some friction. That and some best practices, perhaps in the form of another blog post hint hint 🙂

val_waeselynck12:06:32

Maybe we need to improve the discoverability of such community resources. @marshall, maybe a new section on the Datomic website?

val_waeselynck13:06:05

I'm constantly discovering awesome blog posts and gists that have been around for months

uwo13:06:43

@robert-stuttaford what do you like to use to visualize or reckon about installed schema?

robert-stuttaford13:06:56

@uwo i built a thing over December to help with that https://github.com/Cognician/datomic-doc#search , which helps, but mostly i query the database at the repl 🙂

val_waeselynck16:06:27

@matthewdaniel I cannot speak as to whether the code you posted should work, but I think if you just put the lookup refs in the values (instead of a map with :db/id) it will work. You can also just write {:vendor/number "..."} and rely on upsert behaviour

MegaMatt16:06:02

isn't :db/ident [:vendor/number "123] a lookup ref? the docs don't seem to have another option

MegaMatt16:06:34

i tried removing the db/id stuff and just writing vendor/number '..." but that doesn't work either

MegaMatt16:06:25

is there something i can do to get better error messages than "cognitect.anomalies "Server Error"

MegaMatt16:06:58

well i think i had 2 problems but my initial thing will work. I needed to put my transactions into a vector and I forgot to make vendor/number unique. Thanks for the pointers @val_waeselynck

hmaurer17:06:38

Hi! I am completely new to Datomic and I have two quick questions: (1) I just read http://docs.datomic.com/backup.html but from what I understand Datomic can work on top of various datastores (postgres, dynamodb, etc). Would a backup of the underlying datastore suffice?

hmaurer17:06:08

(2) if I run into issues using datomic, how responsive is the community? (I guess this question will answer itself 😄)

ghadi18:06:18

@hmaurer for support -- there are support contracts and there's also a lot of free resources in http://www.datomic.com/support.html

timgilbert18:06:44

@hmaurer: 1. I've found the datomic backups to be super straightforward and painless so I've never tried just backing up the underlying storage (also the datomic backups don't take down your storage while they run in case that's an issue). 2. I've found the community to be responsive and friendly, if a little small. In addition to this channel, the mailing list is also worth checking: https://groups.google.com/forum/#!forum/datomic

eriktjacobsen19:06:00

Have you had to restore from backup after catastrophic failure @timgilbert ?

timgilbert19:06:03

I think we did so one time and it went ok, I wasn't super involved with it though

timgilbert19:06:47

It involves taking down all the transactors, which is unfortunate but makes some sense. The nice thing about having all the history in there is that the need to do it seems to come up a lot less (in my experience so far)

hmaurer20:06:08

I am trying to set up Datomic Starter locally (following the tutorial) but getting this error: https://gist.github.com/hmaurer/b9d303055c7a9b7c4e4827b5b79e2acc

MegaMatt20:06:41

had the same issue myself, you have to make sure you create the database before you connect the peer server to it

hmaurer20:06:42

@matthewdaniel are you sure you had the same issue? this error seems to be about class loading, which create the database shouldn’t impact?

hmaurer20:06:24

I had this error in the first step of the getting started guide

hmaurer20:06:34

i won’t be able to create a databse if the server isn’t running I think?

MegaMatt20:06:50

ah, your right, sorry

hmaurer20:06:11

no worries, thanks for trying to help

hmaurer20:06:23

does it work for you? can you run that first line from the tutorial?

MegaMatt20:06:47

i start with this

MegaMatt20:06:50

bin\transactor.cmd c:\Users\mmeisberger\dev-transactor-template.properties

MegaMatt20:06:00

^ slightly different for windows here

MegaMatt20:06:20

then in a new shell i run the stuff to create the db in the repl then run the peer

MegaMatt20:06:49

yeah, i mostly followed the dev-setup link i guess

hmaurer20:06:38

Trying this now. It’s strange, the instructions are quite different from the getting started guide

hmaurer20:06:43

a bit confusing

MegaMatt20:06:18

yeah, same here.

hmaurer20:06:57

which gives the same command as in the “getting started” guide

hmaurer20:06:01

and spits out the same error

hmaurer20:06:28

“Exception in thread “main” java.io.FileNotFoundException: Could not locate datomic/peer_server__init.class or datomic/peer_server.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.”

hmaurer20:06:17

Oooh my bad

hmaurer20:06:30

I didn’t realise there was a distinction between “datomic free” and “datomic starter”

hmaurer20:06:19

No to excuse my own silliness, but maybe the tutorial should be a bit clearer

hmaurer20:06:48

The “Starter” edition is free, so after creating my account I went to the “Downloads” menu and downloaded the latest version

hmaurer20:06:03

the file was called datomic-free but it didn’t attract my attention and it’s what I was expecting

hmaurer20:06:21

Where in fact I needed Datomic pro with a Starter key

hmaurer20:06:20

Quoting the google groups thread:

hmaurer20:06:29

> The primary use case for Free is not new users, but rather people who need a license that includes redistribution rights.

hmaurer20:06:45

In that case the “Download” section on the dashboard should probably indicate that

MegaMatt21:06:06

cool. glad to here you got it sorted out

hmaurer23:06:35

Hi! Another quick question: are “asOf” queries expensive? For example, can I use this feature to let the user view an old state of a document and all its associations?

hmaurer23:06:05

At an arbitrary point in time

hmaurer23:06:26

Will those queries be expensive if different users try to see their documnts at different points in time?