Ash FrameworkAF
Ash Framework3y ago
6 replies
axdc

Creating an Identity referencing a key within a :map attribute (postgres-stored jsonb)

I have a resource with these attributes:

 attributes do
    uuid_primary_key :id

    attribute :source, :atom do
      constraints one_of: [:source_one, :source_two]
    end

    attribute :original_json, :map
  end


I'd like to create an identity on the resource that uses a key within the map. Is that possible?

identities do
  
  #something like this?
  identity :synthetic_id [:source, :original_json["Key"]]

end


Specifically, I'd like to upsert using this identity. I'm seeing recommendations for Ecto to just do it manually in the database and wondering if there's an Ash Way.
Was this page helpful?