DBIx::Skinny::Schema::ProxyTableRule
package Proj::DB::Schema; use DBIx::Skinny::Schema; use DBIx::Skinny::Schema::ProxyTableRule; install_table 'access_log' => shcema { proxy_table_rule 'strftime', 'access_log_%Y%m'; pk 'id'; columns qw/id/; }; package main; my $rule = Proj::DB->proxy_table->rule('access_log', DateTime->today); $rule->table_name; #=> "access_log_200901" # create table that name is "access_log_200901" $rule->copy_table; my $iter = Proj::DB->search($rule->table_name, { foo => 'bar' });
DBIx::Skinny::Schema::ProxyTableRule export proxy_table_rule method. You can call proxy_table_rule method in install_table method.
1st argumet is funtion name (strftime or sprintf) or CODEREF
If you define rule followings: package Proj::DB::Schema; use DBIx::Skinny::Schema; use DBIx::Skinny::Schema::ProxyTableRule;
install_table 'access_log' => schema { proxy_table_rule 'strftime', 'access_log_%Y%m'; };
you can call followings:
my $rule = Proj::DB->proxy_table->rule('access_log', DateTime->now); $rule->table_name #=> "access_log_201002"
install_table 'access_log' => schema { proxy_table_rule 'sprintf', 'access_log_%04d%02d'; };
my $now = DateTime->now; my $rule = Proj::DB->proxy_table->rule('access_log', $now->year, $now->month); $rule->table_name #=> "access_log_201002"
You can define custom function.
my $code = sub { my ($template, @args) = @_; sprintf($template, @args); }; install_table 'access_log' => schema { proxy_table_rule \$code, 'access_log_%02d%02d'; };
Keiji Yoshimi <walf443 at gmail dot com>
+<DBIx::Skinny::ProxyTable>, +<DBIx::Skinny::ProxyTable::Rule>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install DBIx::Skinny::ProxyTable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Skinny::ProxyTable
CPAN shell
perl -MCPAN -e shell install DBIx::Skinny::ProxyTable
For more information on module installation, please visit the detailed CPAN module installation guide.