Fork me on GitHub
#datomic
<
2017-05-05
>
robert-stuttaford06:05:18

@jdkealy absolutely yes it can

stijn11:05:59

has anyone ever written a (db) function that takes the nested map form of an entity in transaction and also generates :db/retract's (based on e.g. 'nil' values for fields or missing values in a many relationship)?

stijn11:05:28

or how are you all dealing with this when arbitrarily nested data structures need to be updated?

augustl12:05:55

@stijn Datomic sure likes flat data/facts 🙂 Usually ended up with something non-generic and/or tried to flatten my data as much as i can

michaelr12:05:14

I have a growing number of orders in the DB. I would like to expose an API which would return these orders between dates, as given in a parameter. The simplest thing to do would be to make a query and then iterate over the returned entities. But what is the best way to implement pagination of results?

stijn12:05:53

@michaelr use the :avet index on :order/date and return a 'next-page' token to the client based on either the date, or if you want a fixed set of results the date + the entity id

stijn12:05:40

@augustl yes, but I was looking for something generic because i'm fed up implementing the non-generic 🙂

michaelr12:05:07

@stijn Thanks! Will check the docs on how to query an index

stijn12:05:33

@michaelr you can do that with d/datoms

michaelr13:05:32

@stijn Checking.. thanks

michaelr13:05:42

@stijn No way to specify (> some-date) for the value? Should I be iterating over the whole index?

stijn13:05:17

(d/datoms db :avet (d/entid db :order/date) from-date) will give you all entities as of from-date

michaelr13:05:12

Wow interesting

favila13:05:44

@stijn that will give you entities with exactly from-date only

favila13:05:37

But @michaelr see d/index-range

michaelr13:05:59

@favila Thanks. Will check it now

michaelr13:05:56

@favila This one works! 🙂

stijn13:05:14

oh yes 🙂