jechol
Ash_req_opt - shortcut DSL for attributes and relationships in Ash resources
Hi everyone ![]()
I recently published a small utility library called ash_req_opt, and I wanted to share it here in case it might be useful for others building with Ash Framework.
What is it?
ash_req_opt is a DSL shortcut for declaring attributes and relationships in Ash resources with commonly used allow_nil? and public? options.
Ash is powerful, but sometimes writing repetitive attribute or belongs_to definitions with the same flags gets a bit tedious. This library simplifies that by providing macros like req, opt, req_belongs_to, etc.
Example
defmodule MyApp.User do
use Ash.Resource, extensions: [AshReqOpt]
attributes do
uuid_primary_key :id
req :email, :string
req_prv :password_hash, :string
opt :name, :string
opt_prv :last_login_at, :utc_datetime
# fallback to native Ash DSL still works
attribute :nickname, :string, allow_nil?: true
end
relationships do
req_belongs_to :company, Company
req_prv_belongs_to :created_by, User
opt_belongs_to :manager, User
opt_prv_belongs_to :updated_by, User
belongs_to :department, Department, allow_nil?: true
end
end
It’s a small layer, but I hope it helps others too. Feedback, feature suggestions, or improvements are welcome!
Hex: https://hex.pm/packages/ash_req_opt
GitHub:
Popular in Libraries
I’ve just released stable versions of my Prometheus Elixir libs:
Elixir client [docs];
Ecto collector [docs];
Plugs instrumenter/Export...
New
Dune is a sandbox for Elixir and aims to safely evaluate user-provided code.
You can try it out using this basic Elixir playground made ...
New
Hi!
I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
https://www.conduitframework.com/
The best overview for how things are tied together is this presentation. Modules and functions are pre...
New
EctoJob
A transactional job queue built with Ecto, PostgreSQL and GenStage
Available on Hex.pm: ecto_job | Hex
Docs: API Reference — ec...
New
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue.
It’s a seamless integration of Vue and Phoenix LiveView, i...
New
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM.
...
New
Hi, I wanted share a small library we at Revelry Labs made for rendering react components from the server side. There are instructions fo...
New
As the title states, EctoEnum has just been updated after some time of hardly any activity in the repo. Here’s the latest release: https:...
New
Hello!
Came here to announce ChromicPDF, a pet project PDF generator I’ve been working on for the past few months. Why another PDF gener...
New
Other popular topics
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New







