Fork me on GitHub
#datomic
<
2016-01-27
>
jimmy03:01:41

hi guys what is the proper way to update refs in datomic ? Normally I transact many ref like this :user/comments #{1 2 4 5} but when I re update it with :user/comments #{1 2}. It doesn't seem to change

bhagany03:01:01

@nxqd: in that case, you'd have to issue retractions for 4 and 5

bhagany03:01:46

datomic doesn't replace the whole set like you seem to want

bhagany03:01:22

I find it helpful to remember that the map form of transactions always expands to vector forms that begin with :db/add

bhagany03:01:48

so, your original transaction expands to [[:db/add 123 :user/comments 1] [:db/add 123 :user/comments 2] [:db/add 123 :user/comments 4] [:db/add 123 :user/comments 5]]

bhagany03:01:34

and your second transaction expands to [[:db/add 123 :user/comments 1] [:db/add 123 :user/comments 2] ], which means you're just re-asserting 1 and 2, but not doing anything with the already-existing 4 and 5

jimmy03:01:58

hmm, that explains. so if I have to do it manually I have to do [[:db/remove :user/comments 4]] ?

bhagany03:01:27

yes, but it's :db/retract

jimmy03:01:46

for example if I want to 'just update' then I have to retract all and add the new ones ( most simple way ) or I have to find which one is new and which is not then explicitly add or retract those ( which is more complex )

bhagany03:01:09

yes, those are your options

jimmy03:01:39

ok, thanks for helpful insight simple_smile

bhagany03:01:49

you're welcome simple_smile

bhagany03:01:05

I suppose I should point out that this only applies to :cardinality/many attributes. For :cardinality/one, datomic will do the retraction for you

jimmy03:01:35

@bhagany: it's good to know

jimmy03:01:01

I just found out this gist, stuart does point out how to retract all refs. https://gist.github.com/stuarthalloway/2948756

jimmy03:01:33

It would be a bit easier, now I need to find a general way to solve this

ebahsini05:01:12

Any good walkthroughs for Datomic that aren't groovy based?

jimmy06:01:14

@ebahsini: java or clojure ? There are tutorials on frontend page of datomic ( it's in java ) and another one in clojure in a Datomic org on github. You can find it right away.

isaac12:01:17

can not add partition and enum type at the same transact

{:db/id #db/id[:db.part/db]
  :db/ident :table
  :db.install/_partition :db.part/db}
[:db/add #db/id[:table] :db/ident :resource.type/table]

isaac12:01:29

First, I install partition table. And then add entity to this partition. It will throw exception.

Lambda/Sierra15:01:13

@isaac: That is correct: You cannot create a partition and create entities in that partition within the same transaction. The same is true for attributes: You cannot create an attribute and use it in the same transaction.

isaac15:01:56

@stuartsierra: Yeah, thanks. I separated it into two transaction.

meow21:01:39

I'm trying to install Datomic Pro Starter Edition on Windows 10 - I can't run bin/maven-install because there is no .cmd file equivalent. What gives?

currentoor21:01:39

I'm trying to store a JSON blob as :db.type/bytes but I get this error

ERROR java.lang.IllegalArgumentException: :db.error/wrong-type-for-attribute Value {:href "", :method "POST", :title "corge (Phrase)"} is not a valid :bytes for attribute :action/form
Any suggestions? Also is bytes even the right type?

currentoor21:01:21

What are the requirements for something to be storable as bytes?

meow21:01:05

The Datomic "Getting Started" isn't giving me any warm fuzzies - more like I feel like an idiot. Just FYI.

meow21:01:12

Seriously, does nobody install Datomic on Windows?

jonahbenton22:01:11

hey @currentoor a json blob should be put into a :db.type/string

currentoor22:01:02

@jonahbenton: i plan on storing error information that could be on the order of a megabyte in size. Is that ok?

jonahbenton22:01:58

@currentoor my understanding is that current design considerations around datom storage are in the vein of a max of low 10s of k for strings. so writing and retrieving blobs closer to a MB in size is considered "suboptimal" for some definition of suboptimal. whether it's ok probably depends on your use case, throughput requirements, etc.

Lambda/Sierra22:01:21

@meow: bin/maven-install is only needed if you're going to use the Datomic Peer libraries with Java or Clojure tools that use Maven for dependency resolution, such as Maven or Leiningen.

Lambda/Sierra22:01:42

bin/maven-install is a very simple script that just calls the Maven command-line executable.

meow22:01:43

Assuming that were the case, how does one do that on Windows 10?

Lambda/Sierra22:01:57

I'm afraid I don't know exactly, but if you have Maven (http://maven.apache.org) installed you should be able to copy the mvn command from bin/maven-install.

meow22:01:39

Since I'm just starting with it and it isn't critical I'm putting it off for a few days. Not in the mood.

meow22:01:35

No offense, I appreciate the help. Just don't feel like I should need it just to install the thing.

currentoor22:01:55

@jonahbenton: thanks for the advice.

jonahbenton23:01:19

hey @meow hit me up when you want to come back to it, happy to help