zenchild

zenchild

Ash.DataLayer.Mnesia - table name

I’m playing around with the Mnesia datalayer while I’m going through the Ash book. I wanted to give it a go instead of the postgresql datalayer. I’m setting an explicit table name (:artists), but it still wants to use the module name as the table. Am I configuring it wrong? Here’s my resource module:

defmodule AshMnesia.Music.Artist do
  use Ash.Resource,
    otp_app: :ash_mnesia,
    domain: AshMnesia.Music,
    data_layer: Ash.DataLayer.Mnesia

  mnesia do
    table :artists
  end

  actions do
    defaults [:read, :destroy]

    create :create do
      accept [:name]
    end

    update :update do
      accept [:name]
    end
  end

  attributes do
    uuid_v7_primary_key :id

    attribute :name, :string do
      allow_nil? false
    end
  end
end

Even though I’m explicitly specifying a table, the below still is using an mnesia table called AshMnesia.Music.Artist.

> AshMnesia.Music.Artist |> Ash.Changeset.for_create(:create, %{name: "Daisy Jones"}) |> Ash.create

Thanks for any help anyone can give. :folded_hands:

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

Fixed in main of ash. With a commit aptly entitled

fix: actually use the mnesia table configured :man_facepalming:

Last Post!

zenchild

zenchild

Thanks @zachdaniel! I just started digging into the code and cloned the repo to fix it and noticed you already did :laughing:

Much appreciated!

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement