Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Split off of WWW::App::MVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Totten committed Feb 28, 2013
0 parents commit 3ccc373
Show file tree
Hide file tree
Showing 5 changed files with 789 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Makefile
blib/
18 changes: 18 additions & 0 deletions META.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name" : "WWW::App::MVC",
"version" : "*",
"description" : "MVC Framework for Web Apps in Perl 6.",
"depends" :
[
"WWW::App",
"SCGI",
"FastCGI",
"HTTP::Easy",
"Template6",
"Flower",
"DB::Model::Easy",
"DateTime::Utils",
"JSON::Tiny"
],
"source-url" : "git://github.com/supernovus/perl6-www-app-mvc.git"
}
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# DB::Model::Easy

## Introduction

A simple set of base classes for building easy database models.

## Example Model Library

```perl
use DB::Model::Easy;
class MyModel::User is DB::Model::Easy::Row {
has $.id;
has $.name is rw;
has $.age is rw;
has $.job is rw;

## Rules for mapping database columns to object attributes.
## 'id' is a primary key, auto-generated. The column for 'job' is called 'position'.
has @.fields = 'id' => {:primary, :auto}, 'name', 'age', 'job' => 'position';
}
class MyModel is DB::Model::Easy {
has $.rowclass = MyModel::User;
method getUserById ($id) {
self.get.with(:id($id)).row;
}
}

my $model = MyModel.new(:$table, driver => $db<driver>, opts => $db<opts>);
my $user = $model.getUserById($uid);

## Let's get a list of other users with the same job as our own.
my $others = $model.get.with(:job($user.job)).and.not(:id($user.id)).rows;

...
```

## Notes

This was originally a part of WWW::App::MVC, but I've split it off as its
own library for those who may want to use it separately.

## TODO

* Add tests.

## Author

Timothy Totten. Catch me on #perl6 as 'supernovus'.

## License

Artistic License 2.0

Loading

0 comments on commit 3ccc373

Please sign in to comment.