Begin Message model

This commit is contained in:
swag 2021-12-04 23:06:05 -05:00
parent eba062ebfa
commit e1c07606b5
3 changed files with 18 additions and 5 deletions

View File

@ -29,9 +29,13 @@ helper test => sub {
state $test = GuestbookNg::Model::Test->new(pg => shift->pg) state $test = GuestbookNg::Model::Test->new(pg => shift->pg)
}; };
helper message => sub {
state $test = GuestbookNg::Model::Message->new(pg => shift->pg)
};
# Routes # Routes
under sub ($c) { under sub ($c) {
$c->test->create_table() $c->pg->migrations->from_dir('migrations')->migrate(1);
}; };
get '/' => sub ($c) { get '/' => sub ($c) {

View File

@ -0,0 +1,13 @@
#!/usr/bin/env perl
package GuestbookNg::Model::Message;
use Mojo::Base -base, -signatures;
has 'pg';
sub new($class, $pg, $object) {
bless {$pg => $object}
}
1;

View File

@ -14,10 +14,6 @@ sub test_model($self, $string) {
"you've supplied: $string" "you've supplied: $string"
} }
sub create_table($self) {
$self->pg->migrations->from_dir('migrations')->migrate(1);
}
sub now($self) { sub now($self) {
$self->pg->db->query('SELECT NOW() AS now')->text() $self->pg->db->query('SELECT NOW() AS now')->text()
} }