NAME
DBIO::Core - Standard base class for DBIO result classes
VERSION
version 0.900000
SYNOPSIS
package MyApp::Schema::Result::Artist;
use base 'DBIO::Core';
__PACKAGE__->table('artists');
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
name => { data_type => 'varchar', size => 100 },
bio => { data_type => 'text', is_nullable => 1 },
created_at => {
data_type => 'timestamp',
set_on_create => 1,
},
updated_at => {
data_type => 'timestamp',
set_on_create => 1,
set_on_update => 1,
},
);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->add_unique_constraint(artist_name => ['name']);
__PACKAGE__->has_many(cds => 'MyApp::Schema::Result::CD', 'artist_id');
1;
PostgreSQL-specific example:
package MyApp::Schema::Result::User;
use base 'DBIO::Core';
__PACKAGE__->load_components('InflateColumn::DateTime');
__PACKAGE__->table('users');
__PACKAGE__->add_columns(
id => {
data_type => 'uuid',
retrieve_on_insert => 1,
},
name => { data_type => 'varchar', size => 100 },
role => {
data_type => 'enum',
extra => { list => [qw( admin moderator user guest )] },
is_nullable => 1,
},
metadata => {
data_type => 'jsonb',
default_value => '{}',
serializer_class => 'JSON',
},
embedding => { data_type => 'vector', size => 1536 },
tags => { data_type => 'text[]', is_nullable => 1 },
created_at => {
data_type => 'timestamp',
set_on_create => 1,
},
updated_at => {
data_type => 'timestamp',
set_on_create => 1,
set_on_update => 1,
},
deleted_at => {
data_type => 'timestamp',
is_nullable => 1,
},
);
__PACKAGE__->set_primary_key('id');
1;
DESCRIPTION
DBIO::Core is the normal base class for vanilla DBIO result classes. It collects the standard row, relationship, primary-key, and table-definition behavior that most applications want in every result class.
This is the most verbose but most explicit style. For shorter alternatives, see DBIO::Candy (import-based sugar with hashrefs) or DBIO::Cake (DDL-like DSL).
The bundled components currently are:
- DBIO::InflateColumn
- DBIO::Relationship (See also DBIO::Relationship::Base)
- DBIO::PK
- DBIO::Row
- DBIO::ResultSourceProxy (See also DBIO::ResultSource)
COMMON COLUMN OPTIONS
These options work in add_columns regardless of which style you use:
data_type-- the SQL column type ('integer','varchar','jsonb', etc.)size-- type size (e.g.100forvarchar(100),1536forvector(1536))is_nullable-- set to1for nullable columns (default:0)is_auto_increment-- set to1for auto-increment columnsdefault_value-- Perl scalar or\$sql_literalfor SQL defaultsset_on_create-- set to1to auto-populate on INSERT (e.g. timestamps)set_on_update-- set to1to auto-populate on UPDATE (e.g.updated_at)retrieve_on_insert-- set to1to fetch the DB-generated value after INSERT (e.g. UUIDs)serializer_class-- e.g.'JSON'for automatic JSON inflate/deflateis_foreign_key-- set to1to mark as a foreign key
For a broader tour of what a result class can do, see DBIO::Manual::ResultClass.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.