1 |
package Strix::User; |
package Strix::User; |
2 |
|
|
|
use strict; |
|
|
use warnings; |
|
|
|
|
3 |
use Strix::Schema; |
use Strix::Schema; |
4 |
use Fey::ORM::Table; |
use Fey::ORM::Table; |
5 |
|
|
6 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
|
my $schema = Strix::Schema->Schema(); |
|
7 |
|
|
8 |
has_table( $schema->table('users') ); |
sub collection_table { 'users' } |
9 |
|
|
10 |
|
my $users_table = Strix::Schema->Schema()->table( collection_table ); |
11 |
|
|
12 |
|
has_table( $users_table ); |
13 |
|
|
14 |
|
my $select = |
15 |
|
Strix::Schema->SQLFactoryClass()->new_select() |
16 |
|
->select( $users_table ) |
17 |
|
->from( $users_table ) |
18 |
|
# ->where( $users_table->column('parent_message_id'), '=', Fey::Placeholder->new() ) |
19 |
|
->order_by( $users_table->column('id'), 'ASC' ) |
20 |
|
# ->limit(5) |
21 |
|
; |
22 |
|
|
23 |
|
|
24 |
|
has_many 'foobar' => ( |
25 |
|
table => $users_table, |
26 |
|
select => $select, |
27 |
|
# bind_params => sub { $_[0]->message_id() }, |
28 |
|
); |
29 |
|
|
30 |
|
#warn dump( map { $_->name } $users_table->columns ); |
31 |
|
|
32 |
|
with 'Frey::Collection'; |
33 |
|
|
34 |
1; |
1; |