Catalyst-Helper-Controller-DBIC-API-REST

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

 list_search_exposes

        (1) An arrayref consisting of the name of each column in the class,
        and (2) a hashref keyed on the name of each of the class's has many
        relationships, the values of which are all the columns in the
        corresponding class, e.g.,
    
        list_search_exposes => [
            qw/cdid artist title year/,
            { 'cd_to_producer' => [qw/cd producer/] },
            { 'tags'           => [qw/tagid cd tag/] },
            { 'tracks'         => [qw/trackid cd position title last_updated_on/] },
        ],    # columns that can be searched on via list

CONTROLLERBASE

        Following the advice in L<Catalyst::Controller::DBIC::API/EXTENDING>, this
        module creates an intermediate class between your controllers and
        L<Catalyst::Controller::DBIC::API::REST>.  It contains one method, create,
        which serializes object information and stores it in the stash, which is
        not the default behavior.

lib/Catalyst/Helper/Controller/DBIC/API/REST.pm  view on Meta::CPAN

=head2 list_search_exposes

    (1) An arrayref consisting of the name of each column in the class,
    and (2) a hashref keyed on the name of each of the class's has many
    relationships, the values of which are all the columns in the
    corresponding class, e.g.,

    list_search_exposes => [
        qw/cdid artist title year/,
        { 'cd_to_producer' => [qw/cd producer/] },
        { 'tags'           => [qw/tagid cd tag/] },
        { 'tracks'         => [qw/trackid cd position title last_updated_on/] },
    ],    # columns that can be searched on via list

=head1 CONTROLLERBASE

    Following the advice in L<Catalyst::Controller::DBIC::API/EXTENDING>, this
    module creates an intermediate class between your controllers and
    L<Catalyst::Controller::DBIC::API::REST>.  It contains one method, create,
    which serializes object information and stores it in the stash, which is
    not the default behavior.

t/lib/DBICTest.pm  view on Meta::CPAN

            [ 2, 1, "Forkful of bees",              2001 ],
            [ 3, 1, "Caterwaulin' Blues",           1997 ],
            [ 4, 2, "Generic Manufactured Singles", 2001 ],
            [ 5, 2, "We like girls and stuff",      2003 ],
            [ 6, 3, "Come Be Depressed With Us",    1998 ],
        ]
    );

    $schema->populate(
        'Tag',
        [   [qw/tagid cd tag/],
            [ 1, 1, "Blue" ],
            [ 2, 2, "Blue" ],
            [ 3, 3, "Blue" ],
            [ 4, 5, "Blue" ],
            [ 5, 2, "Cheesy" ],
            [ 6, 4, "Cheesy" ],
            [ 7, 5, "Cheesy" ],
            [ 8, 2, "Shiny" ],
            [ 9, 4, "Shiny" ],
        ]

t/lib/RestTest/Controller/API/REST/CD.pm  view on Meta::CPAN

		[qw/tracks/], {  'tracks' => [qw//] },

    ],

    # Order of generated list
    list_ordered_by         => [qw/cdid/],
    # columns that can be searched on via list
    list_search_exposes     => [
        qw/cdid artist title year/,
        { 'cd_to_producer' => [qw/cd producer/] },
		{ 'tags' => [qw/tagid cd tag/] },
		{ 'tracks' => [qw/trackid cd position title last_updated_on/] },

    ],);

=head1 NAME

 - REST Controller for

=head1 DESCRIPTION

t/lib/RestTest/Controller/API/REST/Tag.pm  view on Meta::CPAN

    # DBIC result class
    class                   =>  'DB::Tag',

    # Columns required to create
    create_requires         =>  [qw/cd tag/],
    # Additional non-required columns that create allows
    create_allows           =>  [qw//],
    # Columns that update allows
    update_allows           =>  [qw/cd tag/],
    # Columns that list returns
    list_returns            =>  [qw/tagid cd tag/],


    # Every possible prefetch param allowed
    list_prefetch_allows    =>  [
        [qw/cd_to_producer/], {  'cd_to_producer' => [qw//] },
		[qw/tags/], {  'tags' => [qw//] },
		[qw/tracks/], {  'tracks' => [qw//] },

    ],

    # Order of generated list
    list_ordered_by         => [qw/tagid/],
    # columns that can be searched on via list
    list_search_exposes     => [
        qw/tagid cd tag/,

    ],);

=head1 NAME

 - REST Controller for

=head1 DESCRIPTION

REST Methods to access the DBIC Result Class tags

t/lib/RestTest/Schema/Result/Tag.pm  view on Meta::CPAN

package # hide from PAUSE
    RestTest::Schema::Result::Tag;

use strict;
use warnings;

use base qw/DBIx::Class::Core/;

__PACKAGE__->table('tags');
__PACKAGE__->add_columns(
  'tagid' => {
    data_type => 'integer',
    is_auto_increment => 1,
  },
  'cd' => {
    data_type => 'integer',
  },
  'tag' => {
    data_type => 'varchar',
    size      => 100,
  },
);
__PACKAGE__->set_primary_key('tagid');

__PACKAGE__->belongs_to( cd => 'RestTest::Schema::Result::CD' );

1;

t/lib/sqlite.sql  view on Meta::CPAN

  cd integer NOT NULL,
  position integer NOT NULL,
  title varchar(100) NULL,
  last_updated_on datetime NULL
);

--
-- Table: tags
--
CREATE TABLE tags (
  tagid INTEGER PRIMARY KEY NOT NULL,
  cd integer NOT NULL,
  tag varchar(100) NOT NULL
);

--
-- Table: producer
--
CREATE TABLE producer (
  producerid INTEGER PRIMARY KEY NOT NULL,
  name varchar(100) NOT NULL



( run in 1.174 second using v1.01-cache-2.11-cpan-5735350b133 )