++ed by:

2 non-PAUSE users.

Al Newkirk

NAME

Doodle

ABSTRACT

Database DDL Statement Builder

SYNOPSIS

  use Doodle;

  my $d = Doodle->new;
  my $t = $d->table('users');

  $t->primary('id');
  $t->uuid('arid');
  $t->column('name');
  $t->string('email');
  $t->json('metadata');

  my $x = $t->create;
  my $g = $d->grammar('sqlite');
  my $s = $g->execute($x);

  say $s->sql;

  # create table "users" (
  #   "id" integer primary key,
  #   "arid" varchar,
  #   "name" varchar,
  #   "email" varchar,
  #   "metadata" text
  # )

DESCRIPTION

Doodle is a database DDL statement builder and provides an object-oriented abstraction for performing schema changes in various datastores. This class consumes the Doodle::Helpers roles.

METHODS

This package implements the following methods.

build

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

Execute a given callback for each generated SQL statement.

build example
  $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
  my $grammar = $self->grammar('sqlite');

schema

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

Returns a new Schema object.

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

statements

  statements(Grammar $g) : [Statement]

Returns a set of Statement objects for the given grammar.

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

table

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

Return a new Table object.

table example
  my $table = $self->table('users');