#include <Wt/WDateTime>
#include <Wt/Dbo/Types>
#include <Wt/Dbo/WtSqlTraits>
class Comment;
class Post;
class User;
namespace dbo = Wt::Dbo;
typedef dbo::collection<dbo::ptr<Comment> > Comments;
class Comment {
public:
dbo::ptr<User> author;
dbo::ptr<Post> post;
dbo::ptr<Comment> parent;
Wt::WDateTime date;
Wt::WString textSrc;
Wt::WString textHtml;
Comments children;
template<class Action>
void persist(Action& a)
{
// normal fields
dbo::field(a, date, "date");
dbo::field(a, textSrc, "text_source");
dbo::field(a, textHtml, "text_html");
// N-1 relations
dbo::belongsTo(a, post, "post");
dbo::belongsTo(a, author, "author");
dbo::belongsTo(a, parent, "parent");
// 1-N relations
dbo::hasMany(a, children, dbo::ManyToOne, "parent");
}
};