Fork me on GitHub
#datomic
<
2016-10-28
>
anders09:10:15

datomic throws exception when i'm (speculatively) applying new attributes with a database as-of some point in time / txid, e.g.:

(d/with (d/as-of db #inst "2016-10-10")
        [{:db/id #db/id[:db.part/db]
          :db/ident :some/attribute
          :db/valueType :db.type/instant
          :db/cardinality :db.cardinality/one
          :db.install/_attribute :db.part/db}])
is this unsupported by datomic or am i missing something here?

anders09:10:49

works fine when applying to db returned from d/db, i.e (d/with (d/db conn) [...tx data...])

robert-stuttaford10:10:51

you can’t as-of AND with, @anders ; as-of is a filter and will filter out all the with-provided data too

robert-stuttaford10:10:37

.... at least, that’s what should happen. d/with basically ignores d/as-of and uses the latest db to build on, but then as-of filters it

anders10:10:44

i certainly works when the data provided isn't attribute definitions

robert-stuttaford10:10:05

it has weird interactions. basically, as-of + with don’t compose as you’d expect

robert-stuttaford10:10:57

may i ask what the idea behind speculative schema is?

robert-stuttaford10:10:17

curious what problem it’s solving 🙂

anders10:10:05

we're applying inferred facts to the db, so that much of our business logic can assume (non-durable / inferred) facts actually is part of the databaase

robert-stuttaford10:10:36

ah so you’re modelling temporary data

robert-stuttaford10:10:58

you could make in-memory dbs and datalog-query across it and durable db

anders10:10:00

inferred i would say

robert-stuttaford10:10:26

it’s a bit extra work because now you have to add representations of durable entities to mem db

anders10:10:44

to solve the problem in question, we will just add the inferred attributes to the stored schema

anders10:10:14

attributes used for the inferred facts i mean

anders10:10:21

we're heavily relying on entity refs, so multiple databases would not work

anders10:10:06

thanks for the insight, @robert-stuttaford

anders10:10:31

obviously adding the inferred attributes to the stored schema won't help; as you say, d/with ignores d/as-of. what a shame 😞

magnars10:10:11

@anders @robert-stuttaford Would it work to "reimplement" as-of by doing a since and transacting the reverse of all those datoms using with?

robert-stuttaford11:10:37

going to have to digest that for a bit, @magnars 🙂

Ben Kamphaus12:10:32

I will comment that much of the goal of having a feature like 'with' is prospective. What if I did X. The X is then something you can do. If you apply 'with' to a past db state with as-of you won't be able to then transact datoms to persist that resulting database. You could, kind of as a cleaner suggestion in the same vein as @magnars , just retract all of the since datoms with one 'with' and then consider the resulting db value with the assertions in another 'with'.

Ben Kamphaus12:10:58

That then corresponds to a database value that could be persisted/made the canonical db with those transactions.

karol.adamiec14:10:38

is there a well supported method of deploying a REST peer for datomic?

jaret15:10:47

@karol.adamiec there is no automatic option. However, the command is 1 line and could be worked into a CF script or your own AMI. http://docs.datomic.com/rest.html

karol.adamiec15:10:07

@jaret so any generic amazon ami should work. I copy over the /bin folder to s3 and set the download then start command in user data?

marshall15:10:58

@karol.adamiec there are a number of approaches you could take, but yes, you should be able to use an Amazon linux AMI, get the datomic distribution (either by wget from my-datomic or via an s3 of your own config), unzip it, and start the REST peer

karol.adamiec15:10:38

./rest -p 8001 dev "datomic:<ddb://eu-west-1/dev-datomic>"

karol.adamiec15:10:01

so start command like aobve gives me acess to any db on dev-datomic table ?

marshall15:10:21

you’ll want to control access to the REST endpoint via IAM or IP config or whatever your preferred method

karol.adamiec15:10:05

i was thinking that rest endpoint is absolutely internal inside VPC, with access only from my backend bridge

marshall15:10:32

that would be fine too as long as you’ve configured your instance to only allow access from with the VPC

karol.adamiec15:10:06

for sure, will lock that down 👍