#ifndef __COMMENT_H__ #define __COMMENT_H__ #include #include #include class Comment; using Comments = Wt::Dbo::collection>; class Post; class User; class Comment { public: Wt::Dbo::ptr author; Wt::Dbo::ptr post; Wt::Dbo::ptr parent; Wt::WDateTime date; void setText(const Wt::WString &text); void setDeleted(); const Wt::WString &textSrc() const { return textSrc_; } const Wt::WString &textHtml() const { return textHtml_; } Comments children; template void persist(Action &a) { Wt::Dbo::field(a, date, "date"); Wt::Dbo::field(a, textSrc_, "text_source"); Wt::Dbo::field(a, textHtml_, "text_html"); Wt::Dbo::belongsTo(a, post, "post", Wt::Dbo::OnDeleteCascade); Wt::Dbo::belongsTo(a, author, "author"); Wt::Dbo::belongsTo(a, parent, "parent", Wt::Dbo::OnDeleteCascade); Wt::Dbo::hasMany(a, children, Wt::Dbo::ManyToOne, "parent"); } private: Wt::WString textSrc_; Wt::WString textHtml_; }; #endif // __COMMENT_H__