Fork me on GitHub

is there a version of db.fn/cas that is a nop instead of throwing an exception? my use case is for upserting entities, I’d like to add a uuid if the entity is new, but not change the existing uuid if an entity exists. looking for an elegant way to do this


That'd be pretty easy to write!


without an execption, your entire tx would have to return nil in order to be no-op, so afaik you would need to write a db function that wraps your entire transaction


i.e. [:myCas e a v [list of other facts]] so that if your fact e a v is a no-op you won't return the list of other facts either


execptions for control flow in functional programs? 🙂


@marshall I figured out my problem. My :tx-data wasn’t in a vector, it was just a map. The error message wasn’t helpful :cognitect.anomalies/message “Server Error” It’d be nice if the spec caught this and returned a help message telling a vector was required.


glad you figured it out. I’ll pass along the feedback about the error


Hey, just noticed a typo on the datomic training videos page, under "part II": > Stu also covers the topics of Datomic databses, entities, and schema


@timgilbert Thanks - Ill fix it!


@augustl what if it just adds the same fact again if it exists? so more like upsert than cas


Well, if you have N facts and one call to your own cas fn, if your own fn just returns nil it won't affect the other facts