Sakthibalan
(KeyError) key :id not found in: %Ash.Error.Unknown
I am creating a custom read action to get students by :roll_number and :password.
defmodule MyApp.Students.Student do
use Ash.Resource,
domain: MyApp.Students,
data_layer: AshPostgres.DataLayer,
extensions: [
AshJsonApi.Resource
]
json_api do
type "student"
routes do
base("/students")
get(:read, route: ":id")
index :read
get(:get_by_roll, route: "by_roll")
end
end
actions do
read :read do
primary? true
end
read :get_by_roll do
argument :roll_number, :string, allow_nil?: false
argument :password, :string, allow_nil?: false
filter expr(roll_number == ^arg(:roll_number) && password == ^arg(:password))
end
end
postgres do
table "students"
repo MyApp.Repo
end
attributes do
attribute :id, :uuid do
writable? false
primary_key? true
default &Ecto.UUID.generate/0
allow_nil? false
public? true
end
attribute :first_name, :string do
allow_nil? false
public? true
end
attribute :last_name, :string do
allow_nil? false
public? true
end
attribute :class, :string, public?: true
attribute :section, :string, public?: true
attribute :dob, :date, public?: true
attribute :father_name, :string, public?: true
attribute :mother_name, :string, public?: true
attribute :roll_number, :string, public?: true
attribute :password, :string, public?: true
create_timestamp :inserted_at
update_timestamp :updated_at
end
end
API Endpoint call
localhost:4000/api/students/by_roll?roll_number=100&password=sakthibalan@100
Getting Error:
Exception:
** (KeyError) key :id not found in: %Ash.Error.Unknown{
errors: [
%Ash.Error.Unknown.UnknownError{
error: "** (Postgrex.Error) ERROR 42883 (undefined_function) function ash_elixir_and(boolean, boolean) does not exist\n\n query: SELECT s0.\"id\", s0.\"first_name\", s0.\"last_name\", s0.\"class\", s0.\"section\", s0.\"dob\", s0.\"father_name\", s0.\"mother_name\", s0.\"roll_number\", s0.\"password\", s0.\"inserted_at\", s0.\"updated_at\" FROM \"students\" AS s0 WHERE ((ash_elixir_and(s0.\"roll_number\"::text = $1::text, s0.\"password\"::text = $2::text)))\n\n hint: No function matches the given name and argument types. You might need to add explicit type casts.",
field: nil,
splode: Ash.Error,
bread_crumbs: [],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :unknown
}
]
}
(ash_json_api 1.0.0) lib/ash_json_api/serializer.ex:111: AshJsonApi.Serializer.serialize_one_error/2
Trending in Questions
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Hello !
We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security










First Post!
zachdaniel
The fact that we aren’t handling the error there is bad, please open an issue on ash_json_api. To resolve it, add
”ash-functions”to your installed extensions in your repo, and generate migrations.EDIT: or use
andinstead of&&Last Post!
Sakthibalan
Yes, I already included “ash-functions”.
It’s working good after did this changes EDIT: or use
andinstead of&&Thank you!