Why do I get the error-message?
#!/usr/bin/env perl
use warnings;
use 5.012;
use ORLite {
package => 'My::ORM',
file => 'sqlite_test.db',
create => sub {
my $dbh = shift;
$dbh->do('CREATE TABLE user ( name TEXT NOT NULL, age INTEGER )');
},
};
say My::ORM::User->table;
my $user = My::ORM::User->create( name => 'Alpha', age => 23, );
Output:
user
Can't locate object method "create" via package "My::ORM::User" at ./perl1.pl line 16.
You are trying to use a method which is only available on tables that have a PRIMARY KEY.
Fix the creation query and that will work: