NAME

Doodle

ABSTRACT

Database DDL (= Data Definition Language) Statement Builder

SYNOPSIS

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
# )

DESCRIPTION

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.

INTEGRATES

This package integrates behaviors from:

Doodle::Helpers

LIBRARIES

This package uses type constraints from:

Doodle::Library

ATTRIBUTES

This package has the following attributes:

commands

commands(Commands)

This attribute is read-only, accepts (Commands) values, and is optional.

METHODS

This package implements the following methods:

build

build(Grammar $grammar, CodeRef $callback) : Any

Execute a given callback for each generated SQL statement.

build example #1
# given: synopsis

$self->build($grammar, sub {
  my $statement = shift;

  # e.g. $db->do($statement->sql);
});

grammar

grammar(Str $name) : Grammar

Returns a new Grammar object.

grammar example #1
# given: synopsis

my $type = 'sqlite';

$grammar = $self->grammar($type);

schema

schema(Str $name, Any %args) : Schema

Returns a new Schema object.

schema example #1
# given: synopsis

my $name = 'app';

my $schema = $self->schema($name);

statements

statements(Grammar $g) : Statements

Returns a set of Statement objects for the given grammar.

statements example #1
# given: synopsis

my $statements = $self->statements($grammar);

table

table(Str $name, Any %args) : Table

Return a new Table object.

table example #1
# given: synopsis

my $name = 'users';

$table = $self->table($name);

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

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".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues