DBIx-QuickORM

 view release on metacpan or  search on metacpan

worktrees/dbic-compat-native-features/lib/DBIx/QuickORM/Connection.pm  view on Meta::CPAN

=item $h = $con->forked(@handle_constructor_args)

=item $h = $con->all(@handle_constructor_args)

=item $h = $con->iterator(@handle_constructor_args)

=item $h = $con->any(@handle_constructor_args)

=item $h = $con->first(@handle_constructor_args)

=item $h = $con->one(@handle_constructor_args)

=item $h = $con->count(@handle_constructor_args)

=item $h = $con->delete(@handle_constructor_args)

These are convenience methods that simply proxy to handle objects:

    my $h = $con->handle(@handle_constructor_args)->NAME();

See the methods in L<DBIx::QuickORM::Handle> for more info.

=item $h = $con->by_id(@handle_constructor_args, $method_arg)

=item $h = $con->iterate(@handle_constructor_args, $method_arg)

=item $h = $con->insert(@handle_constructor_args, $method_arg)

=item $h = $con->vivify(@handle_constructor_args, $method_arg)

=item $h = $con->update(@handle_constructor_args, $method_arg)

=item $h = $con->update_or_insert(@handle_constructor_args, $method_arg)

=item $h = $con->find_or_insert(@handle_constructor_args, $method_arg)

These are convenience methods that simply proxy to handle objects:

    my $h = $con->handle(@handle_constructor_args)->NAME($method_arg);

See the methods in L<DBIx::QuickORM::Handle> for more info.

=cut

sub async  { my $self = shift; $self->handle(@_)->async }
sub aside  { my $self = shift; $self->handle(@_)->aside }
sub forked { my $self = shift; $self->handle(@_)->forked }

sub all      { my $self = shift; $self->handle(@_)->all }
sub iterator { my $self = shift; $self->handle(@_)->iterator }
sub any      { my $self = shift; $self->handle(@_)->any }
sub first    { my $self = shift; $self->handle(@_)->first }
sub one      { my $self = shift; $self->handle(@_)->one }
sub count    { my $self = shift; $self->handle(@_)->count }
sub delete   { my $self = shift; $self->handle(@_)->delete }

sub by_id   { my $self = shift; my $arg = pop; $self->handle(@_)->by_id($arg) }
sub iterate { my $self = shift; my $arg = pop; $self->handle(@_)->iterate($arg) }
sub insert  { my $self = shift; my $arg = pop; $self->handle(@_)->insert($arg) }
sub vivify  { my $self = shift; my $arg = pop; $self->handle(@_)->vivify($arg) }
sub update  { my $self = shift; my $arg = pop; $self->handle(@_)->update($arg) }

sub update_or_insert { my $self = shift; my $arg = pop; $self->handle(@_)->upsert($arg) }
sub find_or_insert   { my $self = shift; my $arg = pop; my $h = $self->handle(@_); $h->one($arg) // $h->insert($arg) }

=pod

=item $rows_arrayref = $con->by_ids($source, @ids)

Fetch rows in the specified source by their ids.

B<NOTE:> If all the specified rows are already cached, no DB query will occur.

C<$source> can be a table name, or any object that implements
L<DBIx::QuickORM::Role::Source>.

C<@ids> contains one or more row primary keys. The keys may be a scalar value
such as C<12> if the primary key is a single column. If the source has a
compound primary key you may provide an arrayref with all the key field values,
or a hashref with the C<< field => val >> pairs.

An arrayref of L<DBIx::QuickORM::Row> objects will be returned.

For a table name or source object this is a convenience method that boils down
to:

    $con->handle($source)->by_ids(@ids);

B<Note:> when C<$source> is itself a L<DBIx::QuickORM::Handle>, it is used
directly as the handle rather than wrapped as a subquery source the way
C<< handle() >> would treat it. A primary-key lookup over a derived table is
not meaningful, so the handle is reused as-is.

=cut

sub by_ids {
    my $self = shift;
    my ($from, @ids) = @_;

    my $handle;
    if (blessed($from) && $from->isa('DBIx::QuickORM::Handle')) {
        $handle = $from;
    }
    else {
        $handle = $self->handle(source => $from);
    }

    return $handle->by_ids(@ids);
}

#########################
# }}} HANDLE OPERATIONS #
#########################

########################
# {{{ STATE OPERATIONS #
########################

=pod

=item $bool = $con->state_does_cache

Check if the current row manager handles caching of rows.



( run in 0.759 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )