This repository has been archived by the owner on Apr 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Timothy Totten
committed
Feb 28, 2013
0 parents
commit 3ccc373
Showing
5 changed files
with
789 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Makefile | ||
blib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.