NAME

DBIx::QuickORM::Role::Row - Role defining the common row interface.

DESCRIPTION

Shared behavior for row objects. Consumers provide the low-level state and field accessors (storage state, desync tracking, the various field views); this role builds the higher-level operations on top of them: insert / save / delete, primary-key helpers, field metadata lookups, and link traversal (follow, obtain, insert_related, siblings).

SYNOPSIS

package My::Row;
use Role::Tiny::With;
with 'DBIx::QuickORM::Role::Row';

sub source { ... }
# ...and the other required methods

$row->save;
my @sibs = $row->siblings('some_link');

REQUIRED METHODS

Consumers must provide the state predicates and accessors (source, connection, is_invalid, is_valid, in_storage, is_desynced, has_pending), the sync check (check_sync), the manipulation primitives (force_sync, refresh, discard, update), and the field views (field, raw_field, fields, raw_fields, stored_field, pending_field, raw_stored_field, raw_pending_field, stored_fields, pending_fields, raw_stored_fields, raw_pending_fields, field_is_desynced).

PUBLIC METHODS

$bool = $row->track_desync
$bool = $row->is_stored
$dialect = $row->dialect
$bool = $row->has_field($name)
$affinity = $row->field_affinity($name)
@fields = $row->primary_key_field_list
@values = $row->primary_key_value_list
%pk = $row->primary_key_hash
$pk = $row->primary_key_hashref

Convenience accessors and primary-key helpers built on the source and connection. has_field croaks without a field name; the primary_key_* helpers croak (via check_pk) when the source has no primary key.

$handle = $row->handle(@args)

Return a handle scoped to this row's source and row.

$str = $row->display

Human-readable identifier: the source name plus the primary-key values.

%args = $row->conflate_args($field, $value)

Return the argument list used for inflate/deflate of a single field value.

$row = $row->check_pk

Return the row if its source has a primary key, otherwise croak.

$row = $row->insert_or_save

Save the row if it is already stored, or insert it if it has pending data.

$row = $row->insert

Insert a not-yet-stored row that has pending data; croaks otherwise.

$row = $row->save

Write pending changes for a stored row. Checks the primary key and sync state first; a no-op when there is nothing pending.

$row->delete

Delete the row from storage (requires a primary key).

$handle = $row->follow($link)

Return a handle for the rows reached by following $link from this row.

$row = $row->obtain($link)

Like follow, but for a unique link: returns the single related row.

$row->insert_related($link, \%row_data)

Insert a related row across $link, filling in the linking columns from this row.

Return a handle for rows sharing the same values on the given link's local columns (or an explicit arrayref of fields); includes this row.

SOURCE

The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

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.

See https://dev.perl.org/licenses/