nyakio
I have a list of records that are to be sorted by the inserted_at column, and I would like to test the sorting functionality. In Ecto, I would create a list of the records and use Repo.update to update the inserted_at column with a calculated value so that the records have different timestamps.
I was able to work this out when I made the inserted_at attributed writable and passed it as an attribute to the update action
I would like to have the inserted_at field as a private attribute so that users cannot update it via the form, but this approach does not return updated values.
In my resource I have:
attribute :inserted_at, :utc_datetime_usec do
writable? true
default &DateTime.utc_now/0
match_other_defaults? true
allow_nil? false
end
...
update :update do
argument :inserted_at, :utc_datetime_usec
accept [:email, :language, :creator_id, :tenant_id, :inserted_at]
primary? true
end
And In the test I have:
for invitation <- invitations, i <- 1..length(invitations) do
invitation
|> Ash.Changeset.for_update(
:update,
%{},
private_arguments: %{inserted_at: time_before_or_after(-i * 12000)},
authorize?: false
)
|> Ash.update!()
end
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Quite interesting article Google brought me. Didn’t find any mentions about it here.
What do you think in general? Would you use togethe...
New
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes.
We’re a small ...
New
Other Trending Topics
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
barnabasJ
Hi
You still need to do something with the argument. That’s probably not precisely clear just by reading the Privat Inputs section of the docs. But an argument by itself is not doing anything.
barnabasJ
I would probably go with the context route described in the next section of the Docs.
For example, if you use AshGraphql, the argument would appear in the API. You could set it to
public?: falseto hide it from that layer though. But then you don’t have a good way to supply it yourself if needed.But if you go the context route, you could supply values to AshGraphl in a plug or middleware that would be passed on to the actions.