Begin Message model

This commit is contained in:
swagg boi 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)
};
helper message => sub {
state $test = GuestbookNg::Model::Message->new(pg => shift->pg)
};
# Routes
under sub ($c) {
$c->test->create_table()
$c->pg->migrations->from_dir('migrations')->migrate(1);
};
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"
}
sub create_table($self) {
$self->pg->migrations->from_dir('migrations')->migrate(1);
}
sub now($self) {
$self->pg->db->query('SELECT NOW() AS now')->text()
}