Skip to content

Commit

Permalink
add base row case.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekokak committed Jan 23, 2010
1 parent 6898f99 commit 1123d7b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
Binary file added base_row_class/db/demo_user.db
Binary file not shown.
26 changes: 26 additions & 0 deletions base_row_class/demo.pl
@@ -0,0 +1,26 @@
#! /usr/local/bin/perl
use strict;
use warnings;
use lib qw(./lib);
use Demo::DB;
use Data::Dumper;

my $db = Demo::DB->new;
$db->connect({dsn => 'dbi:SQLite:./db/demo_user.db'});

$db->delete('user');

$db->bulk_insert('user',
[
{ name => 'nekokak' },
{ name => 'kazuho' },
{ name => 'yappo' },
{ name => 'nekoya' },
{ name => 'oinume' },
]
);

my $itr = $db->search('user');

my @json = map { $_->to_json } $itr->all;
warn Dumper \@json;
13 changes: 13 additions & 0 deletions base_row_class/lib/Demo/DB.pm
@@ -0,0 +1,13 @@
package Demo::DB;
use DBIx::Skinny;

package Demo::DB::Schema;
use DBIx::Skinny::Schema;

install_table user => schema {
pk 'id';
columns qw/id name/;
};

1;

13 changes: 13 additions & 0 deletions base_row_class/lib/Demo/DB/Row.pm
@@ -0,0 +1,13 @@
package Demo::DB::Row;
use strict;
use warnings;
use base 'DBIx::Skinny::Row';
use JSON::XS qw/encode_json/;

sub to_json {
my $self = shift;
encode_json($self->get_columns);
}

1;

6 changes: 6 additions & 0 deletions base_row_class/schema/demo.sql
@@ -0,0 +1,6 @@
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
UNIQUE(name)
);

0 comments on commit 1123d7b

Please sign in to comment.