PhoenixKit.Modules.Posts.PostTagAssignment (phoenix_kit v1.7.33)

Copy Markdown View Source

Junction schema for post-tag assignments.

Many-to-many relationship between posts and tags. A post can have multiple tags, and a tag can be assigned to multiple posts.

Fields

  • post_id - Reference to the post
  • tag_id - Reference to the tag

Examples

# Assign tag to post
%PostTagAssignment{
  post_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  tag_id: "018e3c4a-1234-5678-abcd-ef1234567890"
}

Summary

Functions

Changeset for creating a post-tag assignment.

Types

t()

@type t() :: %PhoenixKit.Modules.Posts.PostTagAssignment{
  __meta__: term(),
  inserted_at: NaiveDateTime.t() | nil,
  post: PhoenixKit.Modules.Posts.Post.t() | Ecto.Association.NotLoaded.t(),
  post_id: UUIDv7.t(),
  tag: PhoenixKit.Modules.Posts.PostTag.t() | Ecto.Association.NotLoaded.t(),
  tag_id: UUIDv7.t(),
  updated_at: NaiveDateTime.t() | nil
}

Functions

changeset(assignment, attrs)

Changeset for creating a post-tag assignment.

Required Fields

  • post_id - Reference to post
  • tag_id - Reference to tag

Validation Rules

  • Unique constraint on (post_id, tag_id) - no duplicate tags on same post