Coder Social home page Coder Social logo

p5-dbix-class-smooth's Introduction

NAME

DBIx::Class::Smooth - Sugar for DBIx::Class

Requires Perl 5.20+ Travis status Distribution kwalitee CPAN Testers result coverage 68.8%

VERSION

Version 0.0101, released 2018-11-29.

SYNOPSIS

#* The schema
package Your::Schema;

use parent 'DBIx::Class::Smooth::Schema';

__PACKAGE__->load_namespaces;


#* The project-specific DBIx::Class::Candy subclass
package Your::Schema::Result;

use parent 'DBIx::Class::Smooth::Result';
sub base {
    return $_[1] || 'Your::Schema::ResultBase';
}
sub default_result_namespace {
    return 'Your::Schema::Result';
}


#* The project-specific base class for your result sources
package Your::Schema::ResultBase;

use parent 'DBIx::Class::Smooth::ResultBase';
__PACKAGE__->load_components(qw/.../);


#* A couple of result source definitions
package Your::Schema::Result::Publisher;

use Your::Schema::Result -components => [qw/.../];
use DBIx::Class::Smooth::Fields -all;

primary id => IntegerField(auto_increment => true);
    col name => VarcharField(size => 100);


package Your::Schema::Result::Book;

use Your::Schema::Result -components => [qw/.../];
use DBIx::Class::Smooth::Fields -all;

primary id => IntegerField(auto_increment => true);
belongs Publisher => ForeignKey();
    col isbn => VarcharField(size => 13);
    col title => VarcharField(size => 150);
    col published_date => DateField();
    col language => EnumField(indexed => 1, -list => [qw/english french german spanish/]);


#* The project-specific DBIx::Class::Candy::ResultSet subclass
package Your::Schema::ResultSet;

use parent 'DBIx::Class::Smooth::ResultSet';

sub base { $_[1] || 'Your::Schema::ResultSetBase' }


#* The project-specific base class for your resultsets
package Your::Schema::ResultSetBase;

use parent 'DBIx::Class::Smooth::ResultSetBase';

__PACKAGE__->load_components(qw/
    Helper::ResultSet::DateMethods1
    Smooth::Lookup::DateTime
/);


#* In the Book resultset
package Your::Schema::ResultSet::Book;

use Turf::Schema::ResultSet -components => [qw/.../];
use DBIx::Class::Smooth::Q;

sub get_books_by_year($self, $year) {
    return $self->filter(published_date__year => $year);
}
sub get_books_by_either_isbn_or_title($self, $isbn, $title) {
    return $self->filter(Q(isbn => $isbn) | Q(title => $title));
}


#* Elsewhere, using the Book resultset
my $books = $schema->Book->get_books_by_year(2018);

DESCRIPTION

DBIx::Class::Smooth is a sugar layer for DBIx::Class, partially built on top of DBIx::Class::Candy and DBIx::Class::Helpers.

STATUS

This is experimental, and an early release at that. I'm using this in a couple of non-critical personal projects, so it hasn't seen heavy use. It would not be surprising if there are bad bugs. Also, it's only been tested on MySQL/MariaDB.

More documentation to follow.

SOURCE

https://github.com/Csson/p5-DBIx-Class-Smooth

HOMEPAGE

https://metacpan.org/release/DBIx-Class-Smooth

AUTHOR

Erik Carlsson [email protected]

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Erik Carlsson.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

p5-dbix-class-smooth's People

Contributors

csson avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.