PhoenixKit.Modules.Posts.PostLike (phoenix_kit v1.7.42)

Copy Markdown View Source

Schema for post likes.

Tracks which users have liked which posts. Enforces one like per user per post.

Fields

  • post_id - Reference to the post
  • user_id - Reference to the user who liked

Examples

# User likes a post
%PostLike{
  post_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  user_id: 42
}

Summary

Functions

Changeset for creating a post like.

Types

t()

@type t() :: %PhoenixKit.Modules.Posts.PostLike{
  __meta__: term(),
  inserted_at: NaiveDateTime.t() | nil,
  post: PhoenixKit.Modules.Posts.Post.t() | Ecto.Association.NotLoaded.t(),
  post_id: UUIDv7.t(),
  updated_at: NaiveDateTime.t() | nil,
  user: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t(),
  user_id: integer() | nil,
  user_uuid: UUIDv7.t() | nil,
  uuid: UUIDv7.t() | nil
}

Functions

changeset(like, attrs)

Changeset for creating a post like.

Required Fields

  • post_id - Reference to post
  • user_id - Reference to user

Validation Rules

  • Unique constraint on (post_id, user_id) - one like per user per post