Man pages sections > man3 > DBIx::Class::Schema::KiokuDB

DBIx::Class::Schema::KiokuDB - Hybrid KiokuDB/DBIx::Class::Schema schema

DBIx::Class::Schema::KiokuDB(3pm) User Contributed Perl Documentation DBIx::Class::Schema::KiokuDB(3pm)


DBIx::Class::Schema::KiokuDB - Hybrid KiokuDB/DBIx::Class::Schema schema support.


version 1.23


Load this component into the schema:
    package MyApp::DB;
    use base qw(DBIx::Class::Schema);
Then load the DBIx::Class::KiokuDB component into every table that wants to refer to arbitrary KiokuDB objects:
    package MyApp::DB::Result::Album;
    use base qw(DBIx::Class::Core);
        id => { data_type => "integer" },
        title => { data_type => "varchar" },
        # the foreign key for the KiokuDB object:
        metadata => { data_type => "varchar" },
    # enable a KiokuDB rel on the column:
Connect to the DSN:
    my $dir = KiokuDB->connect(
        schema => "MyApp::DB",
        create => 1,
    # get the connect DBIC schema instance
    my $schema = $dir->backend->schema;
Then you can freely refer to KiokuDB objects from your "Album" class:
    $dir->txn_do(scope => 1, body => sub {
            title => "Blah blah",
            metadata => $any_object,


This class provides the schema definition support code required for integrating an arbitrary DBIx::Class::Schema with KiokuDB::Backend::DBI.


The example in the Synopis assumes that you want to first set up a KiokuDB and than link that to some DBIx::Class classes. Another use case is that you already have a configured DBIx::Class Schema and want to tack KiokuDB onto it.
The trick here is to make sure to load the KiokuDB schema using "__PACKAGE__->define_kiokudb_schema()" in your Schema class:
    package MyApp::DB;
    use base qw(DBIx::Class::Schema);
You can now get the KiokuDB directory handle like so:
    my $dir = $schema->kiokudb_handle;
For a complete example take a look at t/autovivify_handle.t.


KiokuDB managed objects may hold references to row objects, resultsets (treated as saved searches, or results or cursor state is saved), result source handles, and the schema.
Foreign DBIx::Class objects, that is ones that originated from a schema that isn't the underlying schema are currently not supported, but this limitation may be lifted in the future.
All DBIC operations which may implicitly cause a lookup of a KIokuDB managed object require live object scope management, just as normal.
It is reccomended to use "txn_do" in KiokuDB because that will invoke the appropriate transaction hooks on both layers, as opposed to just in DBIx::Class.


DBIx::Class::KiokuDB, KiokuDB::Backend::DBI.


Yuval Kogman <> This software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2014-03-31 perl v5.18.2