chore: working on code smells
This commit is contained in:
@@ -7,6 +7,16 @@ defmodule BDS.Posts.Link do
|
||||
@primary_key {:id, :string, autogenerate: false}
|
||||
@foreign_key_type :string
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
id: String.t() | nil,
|
||||
source_post_id: String.t() | nil,
|
||||
target_post_id: String.t() | nil,
|
||||
source_post: term(),
|
||||
target_post: term(),
|
||||
link_text: String.t() | nil,
|
||||
created_at: integer() | nil
|
||||
}
|
||||
|
||||
schema "post_links" do
|
||||
belongs_to :source_post, BDS.Posts.Post, foreign_key: :source_post_id, references: :id, type: :string
|
||||
belongs_to :target_post, BDS.Posts.Post, foreign_key: :target_post_id, references: :id, type: :string
|
||||
@@ -15,6 +25,7 @@ defmodule BDS.Posts.Link do
|
||||
field :created_at, :integer
|
||||
end
|
||||
|
||||
@spec changeset(t() | Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()
|
||||
def changeset(link, attrs) do
|
||||
link
|
||||
|> cast(attrs, [:id, :source_post_id, :target_post_id, :link_text, :created_at])
|
||||
|
||||
Reference in New Issue
Block a user