NAME

Doodle::Table::Helpers

ABSTRACT

Doodle Table Helpers

SYNOPSIS

use Doodle;
use Doodle::Table;

my $ddl = Doodle->new;

my $self = Doodle::Table->new(
  name => 'users',
  doodle => $ddl
);

DESCRIPTION

Helpers for configuring Table classes.

LIBRARIES

This package uses type constraints from:

Doodle::Library

METHODS

This package implements the following methods:

binary

binary(Str $name, Any %args) : Column

Registers a binary column and returns the Command object set.

binary example #1
# given: synopsis

my $binary = $self->binary('resume');

boolean

boolean(Str $name, Any %args) : Column

Registers a boolean column and returns the Command object set.

boolean example #1
# given: synopsis

my $boolean = $self->boolean('verified');

char

char(Str $name, Any %args) : Column

Registers a char column and returns the Command object set.

char example #1
# given: synopsis

my $char = $self->char('level', size => 2);

date

date(Str $name, Any %args) : Column

Registers a date column and returns the Command object set.

date example #1
# given: synopsis

my $date = $self->date('start_date');

datetime

datetime(Str $name, Any %args) : Column

Registers a datetime column and returns the Command object set.

datetime example #1
# given: synopsis

my $datetime = $self->datetime('published_at');

datetime_tz

datetime_tz(Str $name, Any %args) : Column

Registers a datetime column with timezone and returns the Command object set.

datetime_tz example #1
# given: synopsis

my $datetime_tz = $self->datetime_tz('published_at');

decimal

decimal(Str $name, Any %args) : Column

Registers a decimal column and returns the Command object set.

decimal example #1
# given: synopsis

my $decimal = $self->decimal('point');

double

double(Str $name, Any %args) : Column

Registers a double column and returns the Command object set.

double example #1
# given: synopsis

my $double = $self->double('amount');

enum

enum(Str $name, Any %args) : Column

Registers an enum column and returns the Command object set.

enum example #1
# given: synopsis

my $enum = $self->enum('colors', options => [
  'red', 'blue', 'green'
]);

float

float(Str $name, Any %args) : Column

Registers a float column and returns the Command object set.

float example #1
# given: synopsis

my $float = $self->float('amount');

if_exists

if_exists() : Table

Used with the delete method to denote that the table should be deleted only if it already exists.

if_exists example #1
# given: synopsis

$self->if_exists;

if_not_exists

if_not_exists() : Table

Used with the create method to denote that the table should be created only if it doesn't already exist.

if_not_exists example #1
# given: synopsis

$self->if_not_exists;

increments_big

increments_big(Str $name, Any %args) : Column

Registers an auto-incrementing big integer (8-byte) column and returns the Command object set.

increments_big example #1
# given: synopsis

my $increments_big = $self->increments_big('number');

increments_medium

increments_medium(Str $name, Any %args) : Column

Registers an auto-incrementing medium integer (3-byte) column and returns the Command object set.

increments_medium example #1
# given: synopsis

my $increments_medium = $self->increments_medium('number');

increments_small

increments_small(Str $name, Any %args) : Column

Registers an auto-incrementing small integer (2-byte) column and returns the Command object set.

increments_small example #1
# given: synopsis

my $increments_small = $self->increments_small('number');

integer

integer(Str $name, Any %args) : Column

Registers an integer (4-byte) column and returns the Command object set.

integer example #1
# given: synopsis

my $integer = $self->integer('number');

integer_big

integer_big(Str $name, Any %args) : Column

Registers a big integer (8-byte) column and returns the Command object set.

integer_big example #1
# given: synopsis

my $integer_big = $self->integer_big('number');

integer_big_unsigned

integer_big_unsigned(Str $name, Any %args) : Column

Registers an unsigned big integer (8-byte) column and returns the Command object set.

integer_big_unsigned example #1
# given: synopsis

my $integer_big_unsigned = $self->integer_big_unsigned('number');

integer_medium

integer_medium(Str $name, Any %args) : Column

Registers a medium integer (3-byte) column and returns the Command object set.

integer_medium example #1
# given: synopsis

my $integer_medium = $self->integer_medium('number');

integer_medium_unsigned

integer_medium_unsigned(Str $name, Any %args) : Column

Registers an unsigned medium integer (3-byte) column and returns the Command object set.

integer_medium_unsigned example #1
# given: synopsis

my $integer_medium_unsigned = $self->integer_medium_unsigned('number');

integer_small

integer_small(Str $name, Any %args) : Column

Registers a small integer (2-byte) column and returns the Command object set.

integer_small example #1
# given: synopsis

my $integer_small = $self->integer_small('number');

integer_small_unsigned

integer_small_unsigned(Str $name, Any %args) : Column

Registers an unsigned small integer (2-byte) column and returns the Command object set.

integer_small_unsigned example #1
# given: synopsis

my $integer_small_unsigned = $self->integer_small_unsigned('number');

integer_tiny

integer_tiny(Str $name, Any %args) : Column

Registers a tiny integer (1-byte) column and returns the Command object set.

integer_tiny example #1
# given: synopsis

my $integer_tiny = $self->integer_tiny('number');

integer_tiny_unsigned

integer_tiny_unsigned(Str $name, Any %args) : Column

Registers an unsigned tiny integer (1-byte) column and returns the Command object set.

integer_tiny_unsigned example #1
# given: synopsis

my $integer_tiny_unsigned = $self->integer_tiny_unsigned('number');

integer_unsigned

integer_unsigned(Str $name, Any %args) : Column

Registers an unsigned integer (4-byte) column and returns the Command object set.

integer_unsigned example #1
# given: synopsis

my $integer_unsigned = $self->integer_unsigned('number');

json

json(Str $name, Any %args) : Column

Registers a JSON column and returns the Command object set.

json example #1
# given: synopsis

my $json = $self->json('metadata');

morphs

morphs(Str $name) : ArrayRef[Column]

Registers columns neccessary for polymorphism and returns the Column object set.

morphs example #1
# given: synopsis

my $morphs = $self->morphs('parent');

no_morphs

no_morphs(Str $name) : ArrayRef[Command]

Registers a drop for {name}_fkey and {name}_type polymorphic columns and returns the Command object set.

no_morphs example #1
# given: synopsis

my $no_morphs = $self->no_morphs('profile');

no_timestamps

no_timestamps() : ArrayRef[Command]

Registers a drop for created_at, updated_at and deleted_at columns and returns the Command object set.

no_timestamps example #1
# given: synopsis

my $no_timestamps = $self->no_timestamps;

primary

primary(Str $name, Any %args) : Column

Registers primary key(s) and returns the Command object set.

primary example #1
# given: synopsis

my $primary = $self->primary('id');

string

string(Str $name, Any %args) : Column

Registers a string column and returns the Command object set.

string example #1
# given: synopsis

my $string = $self->string('fname');

temporary

temporary() : Table

Denotes that the table created should be a temporary one.

temporary example #1
# given: synopsis

my $temporary = $self->temporary;

text

text(Str $name, Any %args) : Column

Registers a text column and returns the Command object set.

text example #1
# given: synopsis

my $text = $self->text('biography');

text_long

text_long(Str $name, Any %args) : Column

Registers a long text column and returns the Command object set.

text_long example #1
# given: synopsis

my $text_long = $self->text_long('biography');

text_medium

text_medium(Str $name, Any %args) : Column

Registers a medium text column and returns the Command object set.

text_medium example #1
# given: synopsis

my $text_medium = $self->text_medium('biography');

time

time(Str $name, Any %args) : Column

Registers a time column and returns the Command object set.

time example #1
# given: synopsis

my $time = $self->time('clock_in');

time_tz

time_tz(Str $name, Any %args) : Column

Registers a time column with timezone and returns the Command object set.

time_tz example #1
# given: synopsis

my $time_tz = $self->time_tz('clock_in');

timestamp

timestamp(Str $name, Any %args) : Column

Registers a timestamp column and returns the Command object set.

timestamp example #1
# given: synopsis

my $timestamp = $self->timestamp('verified');

timestamp_tz

timestamp_tz(Str $name, Any %args) : Column

Registers a timestamp_tz column and returns the Command object set.

timestamp_tz example #1
# given: synopsis

my $timestamp_tz = $self->timestamp_tz('verified');

timestamps

timestamps() : ArrayRef[Column]

Registers created_at, updated_at and deleted_at columns and returns the Command object set.

timestamps example #1
# given: synopsis

my $timestamps = $self->timestamps;

timestamps_tz

timestamps_tz() : ArrayRef[Column]

Registers created_at, updated_at and deleted_at columns with timezone and returns the Command object set.

timestamps_tz example #1
# given: synopsis

my $timestamps_tz = $self->timestamps_tz;

uuid

uuid(Str $name, Any %args) : Column

Registers a uuid column and returns the Command object set.

uuid example #1
# given: synopsis

my $uuid = $self->uuid('reference');

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