Skip to content

threefold.models_to_move.core #

fn Comment.new #

fn Comment.new() Comment

new creates a new Comment with default values

struct Comment #

@[heap]
struct Comment {
pub mut:
	id                u32    // Unique comment ID
	user_id           u32    // ID of the user who posted the comment (indexed)
	content           string // The text content of the comment
	parent_comment_id ?u32   // Optional parent comment ID for threaded comments
	created_at        u64    // Creation timestamp
	updated_at        u64    // Last update timestamp
}

Comment represents a generic commenting functionality that can be associated with any other model It supports threaded conversations through parent_comment_id

fn (Comment) user_id #

fn (mut c Comment) user_id(id u32) Comment

user_id sets the user ID for the comment (builder pattern)

fn (Comment) content #

fn (mut c Comment) content(text string) Comment

content sets the content for the comment (builder pattern)

fn (Comment) parent_comment_id #

fn (mut c Comment) parent_comment_id(parent_id ?u32) Comment

parent_comment_id sets the parent comment ID for threaded comments (builder pattern)

fn (Comment) is_top_level #

fn (c Comment) is_top_level() bool

is_top_level returns true if this is a top-level comment (no parent)

fn (Comment) is_reply #

fn (c Comment) is_reply() bool

is_reply returns true if this is a reply to another comment