Fork me on GitHub
#datomic
<
2016-06-17
>
grav06:06:49

A different question: I like the feature that allows me to query a datastructure directly, eg (d/q ‘[:find …] ‘[[:foo :foo/bar 42] [:bar :foo/bar 43]])

grav06:06:35

Is it possible to query a nested datastructure in any way? Eg, converting the nested structure to a list of datoms somehow?

bahulneel09:06:03

yes, for example, you have the following {:foo {:bar 4}}

bahulneel09:06:45

if you make :foo a reference then you can directly store this in datomic

bahulneel09:06:19

will need to provide :db/ids for both maps, however, if you can make :foo a component and datomic will delete the children when you remove foo

bahulneel09:06:02

when you query you just follow the join: [[?e :foo ?foo] [?foo :bar ?bar]]

bahulneel09:06:29

@grav I think I missundersood you question

bahulneel09:06:37

If you're passing in a data-structure rather than a db then you would need to do something like flatten it to datoms.

grav09:06:35

@bahulneel: yes, exactly, I need to convert it to datoms somehow. I cannot find an api for it.

bahulneel09:06:23

@grav so, the shape you need is a triple of [E A V] this would mean flattening out the data structure so that each map becomes an entity and then you assign ids to those.

bahulneel09:06:35

depending on the complexity of the data structure and how much you know about it in advance you may want to consider using datascript as any implementation will eventually become some implementation of this

bahulneel09:06:14

or you can use the in memory datomic but you'll have to specify all the schema rather than just the references

rauh09:06:15

@grav: Haven't tried, but you can just create an empty dummy db in your app, then use (d/with ) on it to get back a proper db (it always keeps the database empty). Needs a schema though.

bahulneel10:06:26

@grav: looks like @conaw has some code to help you, the transactions he produces should be directly queriable by d/q

noziar21:06:19

Hi - I am sending a lot of transactions to my database, and many of them are timing out because of the load. I assume that even if there is a timeout, the transaction will still go through as long as the queue on the transactor is not full. Is there a way to detect if the transactor actually starts rejecting transactions? Not sure what to look for in the logs

noziar22:06:31

yes, I did it but I forgot the part about using transactAsync instead of transact - so I ended up having a bunch of timeouts and wanted to figure out if there was a way to detect actual transaction failures at the transactor level. I'm not using CloudWatch so I don't see alarms either

marshall22:06:36

Alarms should be reported in your txor logs as well