Having trouble understanding upsert documentation

Learning Ash and this is the part of the documentation that I’m having a bit of difficulty understanding:
https://hexdocs.pm/ash/create-actions.html#upserts

In the first example, it’s a :create_user create action that will update the email if it exists? But if the user with the email already exists, then it won’t ever update anything in this case since it only accepts email?

In the Targeting Upserts section,

  • with the first example, if the slug already exists, shouldn’t it run the update? Why does the documentation say the upsert will fail?
  • with the filter on change, we’re just saying that we’re removing other user’s articles out of the query, so only the current user’s articles can be affected?
  • Where does the :id come from in ^actor(:id)?

Much appreciated!

:wave: thanks for the great questions! I’ve pushed some new docs up which will be available in the next release. For now you can view the preview docs on GH pages: Create Actions — ash v3.4.71

One small note: that references error_handler being able to take a 2 arity anonymous function, but that will only be true on the next release. As of the current release only an MFA is supported.

2 Likes

Amazing! Much clearer examples. Thank you.

1 Like