Bot::Backbone::Service::Role::Storage - Helper for adding storage to standard modules
version 0.161950
package MyBot::Service::Thing; use Bot::Backbone::Service; with qw( Bot::Backbone::Service::Role::Service Bot::Backbone::Service::Role::Responder Bot::Backbone::Service::Role::Storage ); sub load_schema { my ($self, $conn) = @_; $conn->run(fixup => sub { $_->do(q[ CREATE TABLE IF NOT EXISTS things( name varchar(255), PRIMARY KEY (name) ) ]); }); } # More bot service stuff...
Uses DBIx::Connector to deliver a database handle to a bot service. It provides attributes for configuration the DBI DSN, username, and password and automatically manages the connection to the database using DBIx::Connector.
It also provides a sort of callback for loading the schema, which happens when the connection is first used.
This is the DSN to use when connecting to DBI. See your favorite DBD driver for details.
This is the username to use to connect.
This is the password to use when connecting.
Use this to get at the DBIx::Connector object used to connect to your database.
$service->load_schema($db_conn);
This is called to create the schema for your database. It is passed a reference to the newly created DBIx::Connector object. You should use it to run any DDL statements required to setup your schema. It does nothing to help you handle different flavors of SQL so if you need to do that, the way you do that is completely up to you.
DO NOT try to call "db_conn" on the invocant or your bot will lock up, just use the one passed in.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
This software is copyright (c) 2016 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Bot::Backbone, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bot::Backbone
CPAN shell
perl -MCPAN -e shell install Bot::Backbone
For more information on module installation, please visit the detailed CPAN module installation guide.