datomic

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!

2021-06-03T16:39:18.162400Z

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?

2021-06-03T16:57:18.163200Z

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.

2021-06-03T16:58:04.163400Z

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?"]]}

2021-06-03T17:02:22.164100Z

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 šŸ™‚

2021-06-03T17:03:14.164500Z

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!!

2021-06-03T17:04:53.164900Z

Thanks Joe!