Class::ReluctantORM::Relationship::HasLazy
# Declare a column to be lazy Pirate->has_lazy('diary'); # Now you have: $pirate = Pirate->fetch_with_diary($pirate_id); @bipeds = Pirate->fetch_by_leg_count_with_diary(2); # Get info about the relationship $rel = Pirate->relationships('diary'); $str = $rel->type(); # 'has_lazy'; $str = $rel->linked_class(); # undef; $str = $rel->linking_class(); # 'Pirate'; @fields = $rel->local_key_fields(); # field in Pirate that is lazy-loaded # by this relationship, always one @fields = $rel->remote_key_fields(); # empty list $int = $rel->join_depth(); # 0 # Class::ReluctantORM::SQL integration @sql_cols = $rel->additional_output_sql_columns(); @cols = $rel->local_key_sql_columns(); @cols = $rel->remote_key_sql_columns(); # empty list @empty = $rel->join_local_key_sql_columns(); # always empty for HasLazy @empty = $rel->join_remote_key_sql_columns(); # always empty for HasLazy
The HasLazy relationship permits a class to be loaded from the database without loading all of its columns. If a field is declared has_lazy, the column will not be fetched from the database unless it is explicitly mentioned in a fetch_deep 'with' clause.
Unlike other relationships, HasLazy does not link to another CRO class. Nor does it require a remote table, as it draws its data from the base table.
HasLazy relationships do not have inverse relationships.
HasLazy also provides integration via the build_class method of Class::ReluctantORM. This is merely for convenience; behind the scenes, has_lazy will be called for you.
By providing either of these two options, you can automatically set up many Lazy columns quickly.
Optional array ref. List of fields that should be made Lazy. Mutually exclusive with non_lazy_fields.
Optional array ref. If provided, ALL fields are assumed to be lazy, EXCEPT those listed here and primary and foreign keys. Mutually exclusive with non_lazy_fields.
Indicates that the given field should be lazy-loaded, meaning that is not automatically fetched during a regular fetch.
You can cause the field to be fetched by using fetch_deep or calling $obj->fetch_FIELD().
The field will not appear on the 'essential_fields' list, but it will appear on the 'field_names' list.
Note that the value passed to has_lazy is a field name, not a column name; for some classes, they may be different. This is configured by passing a hashref as the value of the 'fields' option to build_class.
The accessor/mutator will behave similarly to a HasOne accessor, in that it will die on access if the value has not been fetched.
Returns 'has_lazy'.
Returns true.
Returns 0.
Returns 'NONE'
Returns 0 - this is a relationship that doesn't link to another table.
To install Class::ReluctantORM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::ReluctantORM
CPAN shell
perl -MCPAN -e shell install Class::ReluctantORM
For more information on module installation, please visit the detailed CPAN module installation guide.