A simple application specific wrapper for kiokudb.
# start with the base class: KiokuX::Model->new( dsn => "bdb:dir=/var/myapp/db" ); # later you can add convenience methods by subclassing: package MyApp::DB; use Moose; extends qw(KiokuX::Model); sub add_user { my ( $self, @args ) = @_; my $user = MyApp::User->new(@args); $self->txn_do(sub { $self->insert($user); }); return $user; } # Then just use it like this: MyApp::DB->new( dsn => "bdb:dir=/var/myapp/db" ); # or automatically using e.g. L<Catalyst::Model::KiokuDB>: $c->model("kiokudb");
This base class makes it easy to create KiokuDB database instances in your application. It provides a standard way to instantiate and use a KiokuDB object in your apps.
As your app grows you can subclass it and provide additional convenience methods, without changing the structure of the code, but simply swapping your subclass for KiokuX::Model in e.g. Catalyst::Model::KiokuDB or whatever you use to glue it in.
The instantiated directory. Created using the other attributes at \*(C`BUILD\*(C' time. This attribute has delegations set up for all the methods of the KiokuDB class.
e.g. \*(C`bdb:dir=root/db\*(C'. See \*(L"connect\*(R" in KiokuDB.
Additional arguments to pass to \*(C`connect\*(C'. Can be a hash reference or an array reference.
An optional custom typemap to add. See KiokuDB::Typemap and \*(L"typemap\*(R" in KiokuDB.
KiokuDB, KiokuDB::Role::API, Catalyst::Model::KiokuDB
KiokuDB is maintained using Git. Information about the repository is available on <http://www.iinteractive.com/kiokudb/>
Yuval Kogman <[email protected]>
Copyright (c) 2009 Yuval Kogman, Infinity Interactive. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=