TableDef - Table data definition
1
This document describes version 1.0.9 of TableDef (from Perl distribution TableDef), released on 2023-05-24.
This document describes TableDef, a way to define table data.
In this document, hashes are written in JSON or pseudo-JSON (e.g. contains ellipsis ... or JavaScript-style comments // ...).
...
// ...
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL "NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
A TableDef spec is written in DefHash. It can be used to describe the structure of a relational database table, a CSV file, or an array of hashes. Tools can be written to convert a TableDef hash to SQL's CREATE TABLE statement, or to utilize information in the TableDef hash to format an HTML table, to view a DB grid on the web browser, etc.
From DefHash. Table summary.
From DefHash. Table longer description.
From DefHash.
A hash, where the keys are field names and the values field specification. See "FIELD SPECIFICATION".
Specify the primary key for the table. Either a string containing a single field name, or an array of field names (for multi-field key).
A DefHash.
Sah schema. This property is required.
From DefHash. Field summary.
From DefHash. Field longer description.
Specify the order of field. Must start from 0 and be contiguous.
Whether this field is mandatory to be present. If 0, then function can choose to omit the field.
Specify whether this field can be sorted.
Specify whether this field can be used as a filter.
Specify whether this field must contain unique values.
This specifies that this field should be shown or included on "default view". What default view is will depend on the context or implementation. Usually you can set this to 0 if the field content is too long or wide. For example, in Perl module Perinci::Sub::Gen::AccessTable, if you give detail => 1 to the generated function, it will include all fields except fields that has this property set to 0. To include such fields, you'll need to explicitly issue with.FIELDNAME => 1.
detail => 1
with.FIELDNAME => 1
Please visit the project's homepage at https://metacpan.org/release/TableDef.
Source repository is at https://github.com/perlancar/perl-TableDef.
DefHash
perlancar <perlancar@cpan.org>
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.
This software is copyright (c) 2023, 2016, 2015, 2014 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=TableDef
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
To install TableDef, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TableDef
CPAN shell
perl -MCPAN -e shell install TableDef
For more information on module installation, please visit the detailed CPAN module installation guide.