skeleton insert code
[dbsrgits/DBIx-Data-Store-old.git] / lib / DBIx / Data / Store / Command / Insert / LastInsertId.pm
1 package DBIx::Data::Store::Command::Insert::LastInsertId;
2
3 use Moose;
4 use Method::Signatures::Simple;
5
6 has 'id_column' => (is => 'ro', required => 1);
7
8 has 'insert_call_command' => (is => 'ro', required => 1);
9
10 has 'raw_store' => (is => 'ro', required => 1);
11
12 method execute {
13   $self->insert_call_command->execute;
14   return { $self->id_column => $self->_get_last_insert_id }
15 };
16
17 method _get_last_insert_id {
18   # this should probably involve some sort of call to the raw
19   # store to get the command object from it, but meh
20   $self->raw_store->connection->run(sub {
21     shift->last_insert_id((undef) x 4)
22   });
23 }
24
25 __PACKAGE__->meta->make_immutable;
26
27 1;