Fork me on GitHub
Paulo Bardes02:06:25

@favila Thanks for the tip!


Hi 👋 In Datomic Cloud, what is the recommended way of getting a sorted result set from a query? Two variations on the theme that I’m interested in would be sorted by transaction :db/txInstant or sorted by arbitrary attribute on the entity.


index-pull if there is one :avet or cardinality-many :aevt index that matches your results and desired order


otherwise, just sort in the application


I see, thanks!


I just want to double check, beyond :db/cas and transaction functions, which must be installed, there's no way to ensure a state before transacting, no?

Joe Lane16:06:46

@U09QBCNBY What kind of guarantees are you looking for?


I want to ensure that no other transactions have touched the target datoms entity before committing the transaction. I would use cas, however I need to read one attribute and then set another, sadly.


this is an ad hoc thing, otherwise we would just install a transaction function that could throw if the constraints weren't matched

Joe Lane16:06:45

I'm not sure why cas doesn't support what you want.

Joe Lane17:06:52

{:tx-data [[:db/cas 42 :no/touchy 100 100] [:db/add 9000 :iff/no-touchy-cas "winning?"]]}


AH HA! I just leave the cas'd value the same -- I didn't realize that a single cas would cancel the entire transaction. That's great!!

Joe Lane17:06:47

Yay ACID 🙂


Right of course. Man I ask really embarrassing questions. thanks for entertaining them

Joe Lane17:06:43

Haha, no way @U09QBCNBY I love your questions!!


Thanks Joe!