[Dbix-class] Encapsulate multiple steps for insertion
Tobias
list at funkreich.de
Thu Jan 11 16:08:09 GMT 2007
Hi everybody,
I'm writing a forum application with DBIx::Class and Catalyst. Every post in a
forum is stored using two tables (for performance reasons):
* posts - (DBIC class "Forum::Post")
contains basic data for every post
has_one relationship with Forum::PostText
* post_texts - (DBIC class "Forum::PostText")
contains just the texts
belongs_to Forum::Post
I'm wondering what's the best way to encapsulate this because I don't want to
make calls to several DBIx::Class classes everywhere I want to insert a new
post (i.e. in Catalyst controllers). Should I just create a third class outside
the Schema namespace which utilizes all neccessary DBIx::Class classes for
inserting a new post to hide the underlying separation into two tables from
the rest of the application? What I want is to call _ONE_ method in my
Catalyst controllers to insert a new post into the database. The controller
shouldn't worry if the data gets stored in one, two or ten tables.
Maybe there's some sort of DBIx::Class magic to do this without having to
add an extra layer myself?
Thanks for any suggestions!
--Tobias
More information about the Dbix-class
mailing list