[CDBI] Adding metadata to objects

Peter Speltz peterspeltz at gmail.com
Tue Sep 27 22:46:02 BST 2005

The latest Class::DBI made a change to has_many where you can list
restraints at compile time. I think the syntax is like this:

CD->has_many('rock_tracks'  => Track,  {constraint => [ genre => 'rock' ]} );

The constraint is put in the meta_info  and when you say
CD->rock_tracks you only get back ones with genre rock.

However since you don't know your constraint until run time, perhaps
you could use the limiting form of  the has_many accessor:

CD->has_many(tracks => Track);
my $rock_tracks = CD->tracks(genre=> 'rock');

I don't know if there is a public interface to set meta info.  I'd
like to know.


More information about the ClassDBI mailing list