Doodle
Database DDL (= Data Definition Language) Statement Builder
use Doodle; my $self = Doodle->new; my $table = $self->table('users'); $table->primary('id'); $table->uuid('arid'); $table->column('name'); $table->string('email'); $table->json('metadata'); my $command = $table->create; my $grammar = $self->grammar('sqlite'); my $statement = $grammar->execute($command); # say $statement->sql; # create table "users" ( # "id" integer primary key, # "arid" varchar, # "name" varchar, # "email" varchar, # "metadata" text # )
Doodle is a database DDL ("Data Definition Language" or "Data Description Language") statement builder and provides an object-oriented abstraction for performing schema changes in various datastores. This class consumes the Doodle::Helpers roles.
This package integrates behaviors from:
Doodle::Helpers
This package uses type constraints from:
Doodle::Library
This package has the following attributes:
commands(Commands)
This attribute is read-only, accepts (Commands) values, and is optional.
(Commands)
This package implements the following methods:
build(Grammar $grammar, CodeRef $callback) : Any
Execute a given callback for each generated SQL statement.
# given: synopsis $self->build($grammar, sub { my $statement = shift; # e.g. $db->do($statement->sql); });
grammar(Str $name) : Grammar
Returns a new Grammar object.
# given: synopsis my $type = 'sqlite'; $grammar = $self->grammar($type);
schema(Str $name, Any %args) : Schema
Returns a new Schema object.
# given: synopsis my $name = 'app'; my $schema = $self->schema($name);
statements(Grammar $g) : Statements
Returns a set of Statement objects for the given grammar.
# given: synopsis my $statements = $self->statements($grammar);
table(Str $name, Any %args) : Table
Return a new Table object.
# given: synopsis my $name = 'users'; $table = $self->table($name);
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Doodle, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Doodle
CPAN shell
perl -MCPAN -e shell install Doodle
For more information on module installation, please visit the detailed CPAN module installation guide.