Kevin L. Esteb > XAS-0.04 > XAS::Model::DBM

Download:
XAS-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source   Latest Release: XAS-0.05

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

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.

syntax highlighting: