Fork me on GitHub
#datomic
<
2016-02-12
>
andrewboltachev03:02:25

Hi. Is it possible to get-database-names for datomic:mem://{host}:{port}/* URI? I.e. is is possible for *mem* DB's? Throws an error for me, asking about * in place of db name, but it's already there.

bkamphaus04:02:04

@andrewboltachev: works fine for me:

(d/get-database-names "datomic:mem://*")
("a" "b")

bkamphaus04:02:00

note that in process memory URI is just: datomic:mem://{db-name}

danielstockton07:02:44

do datomic queries always return a set? or can i example, pull out a single value for an attribute?

danielstockton07:02:58

Here for example, I'd like to avoid (first (first

danielstockton07:02:40

but is the result of a query always a vector in a set? i don't mind having to pull things out, it just feels like im missing a trick

danielstockton07:02:43

ffirst is useful

dm307:02:52

you can do [:find ?v . to get a single item

dm307:02:22

or [:find [?v] to get a seq

danielstockton07:02:58

thanks dm3, that was the trick i was missing

danielstockton07:02:04

is there a name for that ., documented somewhere?

dm307:02:46

important to note that :find ?a . will just return the first item, even if there are more results

bkamphaus14:02:13

@danielstockton: it’s worth mentioning that Datomic query doesn’t return a set of tuples by default just to be arbitrary. This behavior is the means by which you can compose queries. (It’s a similar story with SQL select and result tables/sets). That said, as others mentioned, for returning an (expected) single value or one collection, etc, that’s the exact use case that find specifications exist for.

danielstockton14:02:18

Yep, understood. I actually tried implementing datalog on a toy project but didnt get into all the nitty gritty and special syntax

stuartsierra14:02:31

@currentoor: Not quite. sqUUIDs have leading bits making a timestamp with an accuracy of 1 second. Multiple d/squuids created within the same second will be randomly ordered. Also, clock on different peers may not be in sync, so the timestamps in the sqUUIDs generated on different peers may not reflect the order in which they were transacted.

currentoor18:02:50

@stuartsierra: Makes sense, thanks.

currentoor18:02:38

I have an id attribute on entities and this attribute is only set when the entity is created and it is never updated. If I want to sort a collection of entities by created-at times, I guess I can use the transaction time of that id attribute. Is this fine or is there a preferred way to do it?

bkamphaus18:02:47

@currentoor: that’s the approach I’d probably recommend (as long as you’re sure about the guarantee that it’s set at creation time and never changed), see answer here: http://stackoverflow.com/questions/24645758/has-entities-in-datomic-metadata-like-creation-and-update-time

currentoor18:02:33

@bkamphaus: sounds good, Thanks!