Ask questions on the official Q&A site at https://ask.datomic.com!
Paulo Bardes 2021-06-03T02:23:25.160100Z

@favila Thanks for the tip!

prnc 2021-06-03T12:29:17.160600Z

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.

favila 2021-06-03T12:36:29.160700Z

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

favila 2021-06-03T12:36:41.160900Z

otherwise, just sort in the application

prnc 2021-06-03T12:44:51.161100Z

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 Lane 2021-06-03T16:47:46.163Z

@uwo 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 Lane 2021-06-03T16:59:45.163700Z

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

Joe Lane 2021-06-03T17:00:52.163900Z

{: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 Lane 2021-06-03T17:02:47.164300Z

Yay ACID šŸ™‚


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

Joe Lane 2021-06-03T17:03:43.164700Z

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


Thanks Joe!