The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Jifty::DBI::Schema - Use a simple syntax to describe a Jifty table.

SYNOPSIS

package Wifty::Model::Page::Schema; use Jifty::DBI::Schema;

DESCRIPTION

Each Jifty Application::Model::Class module describes a record class for for a Jifty application. Each column statement sets out the name and attributes used to describe the column in a backend database, in user interfaces, and other contexts. For example:

    column content =>
       type is 'text',
       label is 'Content',
       render_as 'textarea';

defines a column called "content" that is of type "text". It will be rendered with the label "Content" (note the capital) and as a "textarea" in a HTML form.

Jifty::DBI::Schema builds a Jifty::DBI::Column. That class defines other attributes for database structure that are not exposed directly here. One example of this is the "refers_to" method used to create associations between classes.

FUNCTIONS

All these functions are exported.

column

Set forth the description of a column in the data store.

type

type passed to our database abstraction layer, which should resolve it to a database-specific type. Correct usage is type is 'text'.

default

Give a default value for the column. Correct usage is default is 'foo'.

validator

Defines a subroutine which returns a true value only for valid values this column can have. Correct usage is validator is \&foo.

immutable

States that this column is not writable. This is useful for properties that are set at creation time but not modifiable thereafter, like 'created by'. Correct usage is is immutable.

unreadable

States that this column is not directly readable by the application using $record->column; this is useful for password columns and the like. The data is still accessible via $record->_value(''). Correct usage is is unreadable.

length

Sets a maximum length to store in the database; values longer than this are truncated before being inserted into the database, using Jifty::DBI::Filter::Truncate. Note that this is in bytes, not characters. Correct usage is length is 42.

mandatory

Mark as a required column. May be used for generating user interfaces. Correct usage is is mandatory.

not_null

Same as "mandatory". This is depricated. Currect usage would be is not_null.

distinct

Declares that a column should only have distinct values. This currently does nothing, due to not being implemented in DBIx::DBSchema. Correct usage is is distinct.

input_filters

Sets a list of input filters on the data. Correct usage is input_filters are 'Jifty::DBI::Filter::DateTime'. See Jifty::DBI::Filter.

output_filters

Sets a list of output filters on the data. Correct usage is input_filters are 'Jifty::DBI::Filter::DateTime'. See Jifty::DBI::Filter.

since

What application version this column was last changed. Correct usage is since '0.1.5'.

valid_values

A list of valid values for this column. Jifty will use this to autoconstruct a validator for you. This list may also be used to generate the user interface. Correct usage is valid_values are qw/foo bar baz/.

label

Designates a human-readable label for the column, for use in user interfaces. Correct usage is label is 'Your foo value'.

hints

A sentence or two to display in long-form user interfaces about what might go in this column. Correct usage is hints is 'Used by the frobnicator to to strange things'.

render_as

Used in user interface generation to know how to render the column.

The values for this attribute are the same as the names of the modules under Jifty::Web::Form::Field, i.e.

  • Button

  • Checkbox

  • Combobox

  • Date

  • Hidden

  • InlineButton

  • Password

  • Radio

  • Select

  • Textarea

  • Upload

  • Unrendered

You may also use the same names with the initial character in lowercase.

The "Unrendered" may seem counter-intuitive, but is there to allow for internal fields that should not actually be displayed.

If these don't meet your needs, you can write your own subclass of Jifty::Web::Form::Field. See the documentation for that module.

is

Helper method to improve readability.

by

Helper method to improve readability.

are

Helper method to improve readability.

on

Helper method to improve readability.

EXAMPLE

AUTHOR

BUGS

SUPPORT

COPYRIGHT & LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.