SQL::Tr...ma::View(3)

πŸ’… SQL::Tr...ma::View(3) β€” the view object, bestie edition

okay so this is the manpage for SQL::Translator::Schema::View (yes that's the truncated SQL::Tr...ma::View(3) up in the header, it's just shy) from the User Contributed Perl Documentation, and honestly? she's a whole vibe. let's get into it 🫢

✨ NAME ✨

SQL::Translator::Schema::View β€” it's the SQL::Translator view object. that's the whole assignment. πŸŽ€

🌸 SYNOPSIS 🌸

here's how you actually use her, no cap:

use SQL::Translator::Schema::View;
my $view   = SQL::Translator::Schema::View->new(
    name   => 'foo',                      # name, required
    sql    => 'select id, name from foo', # SQL for view
    fields => 'id, name',                 # field names in view
);

literally that's it, she's born ✨ (and yeah, name is required, don't forget her government name πŸ’€)

πŸ¦‹ DESCRIPTION πŸ¦‹

"SQL::Translator::Schema::View" is the view object. main character energy, nothing more to explain πŸ’…


πŸ‘‘ METHODS πŸ‘‘

πŸ“ new

the object constructor. makes a fresh new view out of thin air:

my $view = SQL::Translator::Schema::View->new;

🧚 fields

gets and sets the fields the constraint is on. she accepts a string, a list, or an arrayref; and hands back an array or an array reference. she'll unique the field names and keeps them in order by the first occurrence of a field name β€” so no dupes, bestie, and order is preserved πŸ™ˆ

$view->fields('id');
$view->fields('id', 'name');
$view->fields( 'id, name' );
$view->fields( [ 'id', 'name' ] );
$view->fields( qw[ id name ] );

my @fields = $view->fields;

look at all those ways to say the same thing, she's flexible like that πŸ’–

🌈 tables

gets and sets the tables the SELECT mentions. accepts a string, a list, or an arrayref; returns an array or an array reference. will unique the table names and keep them in order by the first occurrence of a field name (yes, that's what it says, i don't make the rules 🫠)

$view->tables('foo');
$view->tables('foo', 'bar');
$view->tables( 'foo, bar' );
$view->tables( [ 'foo', 'bar' ] );
$view->tables( qw[ foo bar ] );

my @tables = $view->tables;

⭐ options

gets or appends a list of options on the view. little extras, little garnish πŸŽ€

$view->options('ALGORITHM=UNDEFINED');

my @options = $view->options;

πŸ’€ is_valid

determines whether the view is valid or not. vibe check, basically:

my $ok = $view->is_valid;

πŸ’œ name

get or set the view's name:

my $name = $view->name('foo');

πŸŽ€ order

get or set the view's order:

my $order = $view->order(3);

πŸ”₯ sql

get or set the view's SQL:

my $sql = $view->sql('select * from foo');

πŸ¦‹ schema

get or set the view's schema object:

$view->schema( $schema );
my $schema = $view->schema;

get it, set it, she contains multitudes ✨

🌸 equals

determines if this view is the same as another one. twin check πŸ‘―

my $isIdentical = $view1->equals( $view2 );

πŸ’– AUTHOR πŸ’–

Ken Youens-Clark <kclark@cpan.org>. king behavior, we stan πŸ‘‘

ok that's the whole page, go build some views bestie, you're gonna slay πŸ’…βœ¨

sign-off time πŸŽ€ this little icon was brought to you by perl v5.42.0, dated 2024-12-12 β€” go check the date, it's giving vintage but make it fresh πŸ’œ

πŸ“¦ where this page comes from