blob: bef900ab984fc216ce80a2a097291092c76c5660 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package journalsDBIC;
use Data::Dumper;
#insert entry by hashref
my $journalentry = $schema->resultset('Journals')->create({
date => time(),
fulltext => "Hello world",
image_url => "http://something/"
});
#delete by id
my $journalentry = $schema->resultset('Journals')->find({ id => 1 });
$journalentry->delete();
#update by hashref
my $journalentry = $schema->resultset('Journals')->find({ id => 1 });
$journalentry->update({
fulltext => "New text here",
});
#select by date
my $res = $schema->resultset('Journals')->search({
-and => [
date => [ '>', DateTime->now()->subtract({days => 2}) ],
date => [ '<', DateTime->now() ],
]
});
foreach my $row ($res->all){
print Dumper $row;
}
#select *
#select * from journals basically dump the whole table
my $res = $schema->resultset('Journals')
foreach my $row ($res->all){
print Dumper { $row->get_columns };
}
1;
|