NAME
DBIx::QuickORM::Link - A relationship between two tables.
DESCRIPTION
Describes a directional relationship between a local table and another table: the local columns, the other columns they reference, whether the relationship is unique on the other side, and any aliases naming it. Links are used to build joins and to follow related rows.
A link carries a key derived from its local columns, which lets two links describing the same relationship be merged.
SYNOPSIS
my $link = DBIx::QuickORM::Link->new(
local_table => 'users',
local_columns => ['id'],
other_table => 'posts',
other_columns => ['user_id'],
unique => 0,
);
my $link = DBIx::QuickORM::Link->parse($schema, \%spec);
ATTRIBUTES
- local_table
-
Name of the table the relationship is defined from.
- local_columns
-
Arrayref of column names on the local table.
- other_table
-
Name of the table the relationship points to.
- other_columns
-
Arrayref of column names on the other table.
- unique
-
True when the relationship is unique on the other side (at most one related row).
- key
-
A stable key derived from the local columns, used to match links for merging.
- aliases
-
Arrayref of names this link is known by.
- created
-
Human-readable note of where the link was defined.
- compiled
-
Cached compiled form of the link.
PUBLIC METHODS
- $merged = $link->merge($other)
-
Merge another link describing the same relationship (same local table, other table, and columns) into a new link, combining their
creatednotes and aliases. Croaks if the two links do not describe the same relationship. - $copy = $link->clone(%overrides)
-
Return a new link copied from this one, duplicating the column and alias arrays and dropping the compiled and created state. Any passed overrides win.
- $link = $class->parse(@args)
-
Build a link from a flexible mix of arguments: schema, connection, and source objects, plus a link spec given as a hashref or as key/value pairs. Resolves local and other tables and columns, infers
uniquefrom the schema when possible, and returns a new link (or an existing one when passed a DBIx::QuickORM::Link). Croaks on ambiguous or insufficient input.To look an existing link up by name/alias/table/columns, use
$source->resolve_link(...)(see DBIx::QuickORM::Role::Linked) rather thanparse.
SOURCE
The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.