[CDBI] has_many limiting the search.

"Praveen Hombaiah" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
In a given class, while defining a has_many relationship, is it possible to
setup a search criterion,

for instance.
while defining the following relationship, is there a way to limit the CDs
that are returned, lets say we want to return only CDs that are "in_stock".

Music::Artist->has_many(cds => 'Music::CD');


I understand I could do the following while using the Class,

my @cds = $artist->cds(in_stock => 'Y');

but I want this behavior to be default in the class, and not have the
user do this.

Also, I understand, I could use the mapping technique as follows to achieve this
####################

package Music::Artist;
.
.
.
.
Music::Artist->has_many(cds => [ 'Music::CD' => in_stock_only ]);



package Music::CD
..
..
..
sub in_stock_only {
   # return only  cd's that are in stock.
}

####################

but I'm hoping there is a way to just add this search criterion when I'm
setting up the relationship.

Thanks in advance for your help.

-- 
Regards,
Praveen Hombaiah.

_______________________________________________
ClassDBI mailing list
ClassDBI-Ra3b/[email protected]
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.