Schema for polymorphic comments with unlimited threading depth.
Supports nested comment threads (Reddit-style) with self-referencing parent/child
relationships. Can be attached to any resource type via resource_type + resource_uuid.
Comment Status
published- Comment is visiblehidden- Comment is hidden by moderatordeleted- Comment deleted (soft delete)pending- Awaiting moderation approval
Fields
resource_type- Type of resource (e.g., "post", "entity", "ticket")resource_uuid- UUID of the resourceuser_uuid- Reference to the commenterparent_uuid- Reference to parent comment (nil for top-level)content- Comment textstatus- published/hidden/deleted/pendingdepth- Nesting level (0=top, 1=reply, 2=reply-to-reply, etc.)like_count- Denormalized like counterdislike_count- Denormalized dislike counter
Summary
Functions
Changeset for creating or updating a comment.
Check if comment is deleted.
Check if comment is published.
Check if comment is a reply (has parent).
Check if comment is top-level (no parent).
Types
@type t() :: %PhoenixKit.Modules.Comments.Comment{ __meta__: term(), children: [t()] | Ecto.Association.NotLoaded.t(), content: String.t(), depth: integer(), dislike_count: integer(), inserted_at: DateTime.t() | nil, like_count: integer(), parent: t() | Ecto.Association.NotLoaded.t() | nil, parent_uuid: UUIDv7.t() | nil, resource_type: String.t(), resource_uuid: Ecto.UUID.t(), status: String.t(), updated_at: DateTime.t() | nil, user: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t() | nil, user_uuid: UUIDv7.t() | nil, uuid: UUIDv7.t() | nil }
Functions
Changeset for creating or updating a comment.
Required Fields
resource_type- Type of resource being commented onresource_uuid- UUID of the resourceuser_uuid- Reference to commentercontent- Comment text
Check if comment is deleted.
Check if comment is published.
Check if comment is a reply (has parent).
Check if comment is top-level (no parent).