简体   繁体   中英

DBIx::Class Find or Create objects

I'm using DBIx::Class to model the following:

A Recipe with many Tags . The Tag is shared with other Recipe objects.

While creating a Recipe object I want to create a set of Tag objects and associate them with the newly created Recipe object. (The user enters a list of tags and I only have the name of the tag to go with)

For the Tags I could iterate over the list and find one that matches the user entered name or create a new object manually.

I couldn't find a documented findOrCreate type method in DBIx::Class. Any suggestions ?

如果您有名称的键,则可以使用find_or_create

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM