Fork me on GitHub
#datomic
<
2016-03-15
>
wei01:03:26

is there a good way to remove an entity’s components and assign new ones in the same transaction?

val_waeselynck07:03:11

@wei I wrote a transaction fn which retracts the target entities except for a whitelist of lookup refs, and I use that in combination with the specs that add or update the "replacing" entitires

wei13:03:29

@val_waeselynck: ended up doing something similar

matthavener18:03:14

does datomic support connecting to a SQL store without using SSL? It seems like its passing ssl=<something> even if I leave ‘sql-driver-params’ blank or some innocuous

matthavener18:03:25

well, luckily postgres also has ‘sslmode=disable’, so I’ve fixed this with setting “sql-driver-params=sslmode=disable"

PB19:03:56

When setting up datomic with memcached. Is it preferable to have multiple nodes in the cluster?

PB19:03:05

Does datomic make use of consistent hashing?

jamespw19:03:24

This sounds like Datomic 101 but how do I add a child entity that relates back to a parent entity? For example a University has many Classes. I can add the university and the classes in a single transaction but I can’t add a single new Class to the existing classes. I’ve tried googling and looking through the Datomic docs but hit a wall. What’s the idiomatic way to do this?

Chris O’Donnell19:03:02

@jamespw: If you're looking to add a class that belongs to a university, you need to get the university's entity from the database. You probably added classes to your university originally using something like [:db/id (d/tempid :db.part/user) :class/university #db/id[:db.part/user -1]]. If your university is an existing entity university-entity, you would add a class to it with [:db/id (d/tempid :db.part/user) :class/university university-entity].

hiredman19:03:52

correct me if I am wrong, but if you have an unique attribute on the university, you can also use that right?

jamespw19:03:38

When I created the classes in the initial transaction I used the :university/classes relation and had a vector of classes, as I have a cardinality many ref type for :university/classes

hiredman19:03:42

so you can query datomic to find the entity id of each university, then use that entity id to add more classes

hiredman19:03:15

I have not used datomic very much, but if I recall correctly, if you have a unique attribute on a university like maybe :university/name and you had already transacted a university named "Foo" if you do another transaction that contains something like [#db/id[-1] :university/name "Foo"] the tempid will be resolved to the entity id of the already existing university with the name "Foo"

jamespw20:03:27

Is there a ‘belongs to’ association that’s auto created when I add the one to many ref? I can find the university name but when I try and add a new Class it just overwrites the existing one

jamespw20:03:35

Oh it looks like I can use the underscore association (:university/_classes)

Ben Kamphaus20:03:10

@jamespw can you provide a code example of how how you’re trying to add a new class? If you’re working with entities for each, one mistake you might be making is retrieving a class entity and overwriting its attributes, rather than transacting a new class entity.

jdubie21:03:04

@bkamphaus: it’s very convenient to transact the schema and create the database every time my server process (re)starts. i’ve heard this is not best practice. do you agree? if so what are the specific bad things that will happen if you do this?

(d/create-database datomic-uri)
(let [conn (d/connect datomic-uri)]
  @(d/transact conn schema))

Ben Kamphaus22:03:01

@jdubie: I think it makes the most sense to use something like the approach in conformity - https://github.com/rkneufeld/conformity - where you ensure that schema (and entites, w/e) specified in e.g. an edn file are in the database in the form you specify, but don’t submit spurious transactions.

Ben Kamphaus22:03:13

The create call is pretty much harmless. Additional schema transactions will generate empty transactions (i.e., if nothing to be done, won’t add any datoms apart from the transaction datom itself), so they're not completely idempotent.

jdubie22:03:23

awesome. thanks. very helpful.

elijahchancey23:03:16

Howdy! I’m following the instructions here: http://docs.datomic.com/aws.html and have concluded that I can’t create a transactor on AWS while specifying a VPC. We have a multi-vpc environment and need to be able to create the transactor in a non-default VPC. Help?