NAME

XAS::Model::DBM - Defines helper functions to DBIx::Class methods

SYNOPSIS

use XAS::Model::DBM;

DESCRIPTION

This module is not usually included directly by user level code. It's primiary purpose is to be used as a mixin to a model. This module provides several shortcut methods that make database queries easier. To learn how they work, please consult the DBIx::Class documentation.

You can use this methods in the following fashion.

use XAS::Model::Database 'Tablename';

my $schema = XAS::Model::Database->opendb();

... DBIx::Class version

my @rows = $schema->resultset('Tablename')->search();

... as compared to

my @rows = Tablename->search($schema);

The shortcut require less typing and is slightly more intuitive. Neither approach is "more correct" then the other and sometimes they can be intermixed, especially when searching in related tables.

METHODS

create($class, $schema, ...)

This method is a shortcut for creating records. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the DBIx::Class create() method.

find($class, $schema, ...)

This method is a shortcut for finding a single record. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the DBIx::Class find() method.

search($class, $schena, ...)

This method is a shortcut for record searches. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the DBIx::Class search() method.

search_like($class, $schema, ...)

This method is a shortcut for record searches. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the DBIx::Class search_like() method.

count($class, $schema)

This method is returns count of the record in a table. It takes two parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

find_or_create($class, $schema, ...)

This method is a shortcut to find or create a record. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the DBIx::Class find_or_create() method.

update_or_create($class, $schema, ...)

This method is a shortcut for updating or creating a new record. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the DBIx::Class update_or_create() method.

populate($class, $schena, ...)

This method will load a hash of records into a table. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the DBIx::Class populate() method.

load_records($class, $schema, ...)

This method will load records into an array of hashes based on passed criteria. Any data conversion is done automatically. The array is suitable for the ExtJS 4.1 data model. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the search() method.

read_record($class, $schema, ...)

This method will find a single record which is returned as a hash with any data conversion already done. This hash is suitable for the ExtJS 4.1 data model. It takes two or more parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

...

Other parameters that are passed directly to the find() method.

create_record($class, $schema, $record)

This method will create a single record from a hash. This is done within a transaction and any data conversion is done automatically. Only hash items that match actual fields within the table are stored. It returns a hash that is suitable for the ExtJS 4.1 data model. It takes three parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

$record

The record used to create the table entry.

delete_record($class, $schema, $record)

This method will delete a single record from the database. This is done within a transaction. It returns a hash that is suitable for the ExtJS 4.1 data model. It takes three parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

$record

The record used to delete the table entry.

update_record($class, $schema, $record)

This method will update a single record in the database. This is done within a transaction. Only hash items that match actual fields within the table are updated. It returns a hash that is suitable for the ExtJS 4.1 data model. It takes three parameters:

$class

The DBIx::Class model name. Usually a constant defined within XAS::Model::Database.

$schema

The DBIx::Class schema handle returned from opendb() in XAS::Model::Database.

$record

The record used to update the table entry.

SEE ALSO

DBIx::Class

XAS::Base
XAS::Class
XAS::Constants
XAS::Exception
XAS::System
XAS::Utils

XAS::Apps::Base::Alerts
XAS::Apps::Base::Collector
XAS::Apps::Base::ExtractData
XAS::Apps::Base::ExtractGlobals
XAS::Apps::Base::RemoveData
XAS::Apps::Database::Schema
XAS::Apps::Templates::Daemon
XAS::Apps::Templates::Generic
XAS::Apps::Test::Echo::Client
XAS::Apps::Test::Echo::Server
XAS::Apps::Test::RPC::Client
XAS::Apps::Test::RPC::Methods
XAS::Apps::Test::RPC::Server

XAS::Collector::Alert
XAS::Collector::Base
XAS::Collector::Connector
XAS::Collector::Factory

XAS::Lib::App
XAS::Lib::App::Daemon
XAS::Lib::App::Daemon::POE
XAS::Lib::Connector
XAS::Lib::Counter
XAS::Lib::Daemon::Logger
XAS::Lib::Daemon::Logging
XAS::Lib::Gearman::Admin
XAS::Lib::Gearman::Admin::Status
XAS::Lib::Gearman::Admin::Worker
XAS::Lib::Gearman::Client
XAS::Lib::Gearman::Client::Status
XAS::Lib::Gearman::Worker
XAS::Lib::Net::Client
XAS::LIb::Net::Server
XAS::Lib::RPC::JSON::Client
XAS::Lib::RPC::JSON::Server
XAS::Lib::Session
XAS::Lib::Spool

XAS::Model::Database
XAS::Model::Database::Alert
XAS::Model::Database::Counter
XAS::Model::DBM

XAS::Monitor::Base
XAS::Monitor::Database
XAS::Monitor::Database::Alert

XAS::Scheduler::Base

XAS::System::Alert
XAS::System::Email
XAS::System::Environment
XAS::System::Logger

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (C) 2012 by Kevin L. Esteb

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.