Fork me on GitHub
#datomic
<
2017-01-23
>
Drew Verlee02:01:26

can an entity have attributes with a different namespace? [<e-id> <attribute> ...] [1 :person/name] [1 :movie/title]

Drew Verlee02:01:24

does the "/" in attribute carry any meaning?

podviaznikov04:01:37

I started getting strange error while deleting entity. Message says

"java.lang.IllegalArgumentException: :db.error/reset-tx-instant You can set :db/txInstant only on the current transaction.”
.My delete function looks like this
(defn delete-entity [conn entity-id person-id]
  (t/info "delete-entity" entity-id person-id)
  (d/transact conn [[:db.fn/retractEntity entity-id]]))
. Not sure what is going on and what does that error mean. Any tips? I was able to find only one google search with this error and that one didn’t help

andrethehunter05:01:13

@drewverlee yes, an entity can have attributes from multiple namespaces, it has no special meaning

andrethehunter05:01:42

namespaces do help keep things organised so I’d recommend you don’t mix them

andrethehunter05:01:31

Does anyone know if there’s a way for a database function to return/execute multiple transactions?

andrethehunter05:01:55

I’m doing a data migration in a database function and it needs to do a :db/add for the entity and have a transaction

andrethehunter05:01:23

so (datomic/transact conn [[:db/add id :attribute value]{:db/id #db/id[:db.part/tx] :tx-attribute value2}]) for each entity

Matt Butler12:01:26

Is there a way of running a 'migration function', with either vanilla datomic or conformity? In conformity you might add a migration that says all my users have :user/first-name attributes. But what is the best way to then iterate over all my users and transact that new data for each user?

pesterhazy13:01:33

@mbutler I've needed a "data migration" like that as well

pesterhazy13:01:38

I'd just build my own "migrate" tool that does both schema migrations and data migrations

pesterhazy13:01:58

no need to make a transactor fn for that IMO

Matt Butler13:01:22

@pesterhazy Thanks, that does appear the best answer atm. If anyone else has some experience of this let me know 🙂

marshall13:01:38

@podviaznikov Can you provide more info about the entity ID you’re passing to the function? I would expect that error if, for instance, you tried to call retractEntity on a transaction eid

pesterhazy13:01:14

@mbutler I do this all the time with sql migrations - I don't like any of the existing frameworks and it's so simple to build

Drew Verlee20:01:45

is it possible to use datalog without datomic?

podviaznikov20:01:50

@marshall I’ll double check if it was regular entity id. I think it was, but will check. Thanks!

ejelome21:01:33

hi, can I get an enlightenment how datomic sends and receives data (esp. does it store data or is just a layer to a database)? for example, my old understanding of Client-Server is: Client (e.g. mobile) -> sends data (e.g. JSON) over HTTP -> Server (e.g. Liberator/Pedestal?) -> stores it to Database (e.g. Datomic) ... is this wrong? or something is missing in the flow?

favila22:01:57

In datomic, there are three concepts: storage, transactor, peer

favila22:01:27

storage is where all the data is, mostly key-value of blob values

favila22:01:46

peers read out of storage directly

favila22:01:11

in storage is the address of a transactor (which is the only process allowed to write to storage)

favila22:01:15

peers see this address and connect to a transactor. The transactor gives peers a live stream of writes to datomic (the tx-queue), and also accepts transactions to write.

favila22:01:32

@ejelome That is a rough summary of datomic's system architecture

ejelome22:01:28

hey, awesome summary @favila, so in that case, datomic has its own storage

favila22:01:03

@ejelome well, it has its own expectation for how its keys and values are laid out, but it does not have its own storage service

favila22:01:33

@ejelome it is parasitic on some other tech for storage, e.g. dynamodb, a sql database, cassandra, etc

favila22:01:26

but the only thing it needs is transactional update, blob storage, and retrieval by a key

favila22:01:25

the dev/free transactor uses an embedded h2 database (sql)

ejelome22:01:14

ahhh, so it just says how to store and retrieve data but the actual storage is a separate layer

favila22:01:05

not only storage but networked retrieval

favila22:01:59

e.g. if storage is sql, peers make a sql query (select * from datomic_kvs where id="xxx") against storage to perform "reads"

favila22:01:16

transactors use an insert/update to perform writes

ejelome22:01:52

oh, so it kind of has pre-made way to deal with kind of database you'll store/retrieve the data

favila22:01:10

It's not something you control

ejelome22:01:13

I would assume it's differently handled on diff databases, e.g. rdbms is diff. to nosql is diff. to <insert another kind of db>

favila22:01:21

yes, that is true. but they're all used as key-value stores, there's not that much difference

ejelome22:01:37

ok, now I understand better, but I want to ask two more important questions

ejelome22:01:11

? <-> datomic <-> ?

ejelome22:01:19

basically, the in between

favila22:01:13

Are you aware of the diagram on this page?

ejelome22:01:05

wait a sec I'll read

ejelome22:01:37

great! this answered one of the two question (storage): http://docs.datomic.com/storage.html#outline-container-1

ejelome22:01:28

it's a bit daunting to understand tbh

ejelome22:01:45

so then, knowing that it just provisions a database, does datomic also need some sort of way to handle incoming traffic? e.g. liberator/pedestal?

ejelome22:01:03

or i can handle it on its own

favila22:01:27

what kind of traffic?

ejelome22:01:43

looking at the chart: app <-> client <-> http+transit <-> server the client is liberator/pedestal?

favila22:01:02

these are the arch of datomic itself

favila22:01:09

everything else is in the circle "App"

favila22:01:48

that's where your code is that "uses" datomic as a db and which doesn't care about datomic's arch

ejelome22:01:07

I'm actually confused with the app and client because I usually think of the app as the client itself

favila22:01:18

e.g. if you have a traditional CRUD webapp, you have client, server, and db. swap out DB with something else (e.g. mysql vs datomic), the arch remains the same

favila22:01:30

Your web server is a client to the db

favila22:01:38

the browser is a client to the web server

favila22:01:54

"client" and "server" are relative/relational, not absolute terms

favila22:01:39

where the "client" is depends on your perspective

ejelome22:01:59

so something like: cljs <-> liberator/pedestal <-> datomic

favila22:01:26

for a full web app, sure

ejelome22:01:28

sorry favilla, too dumb about this stack

favila22:01:55

js/html <-> php <-> mysql is an exact analogy

favila22:01:09

there are two clients and two servers

ejelome22:01:53

oh, I was limiting myself with the jargon (e.g. client as strictly front-end), that's why

ejelome23:01:30

ok, going with the big picture: client 1: app (cljs) <-> client 2: server (liberator/pedestal) <-> db (datomic)

ejelome23:01:21

oh nevermind, I'm crammed up

ejelome23:01:50

that should be better I think

ejelome23:01:10

hey @favila, thanks for the patience, really appreciate it, a bit slow to learn the architecture and its flow but I'm finally getting it, have a good dawn 😄