1Rose::DB::Object::Std::UMseetradCaotnat(r3i)buted Perl DRoocsuem:e:nDtBa:t:iOobnject::Std::Metadata(3)
2
3
4
6 Rose::DB::Object::Std::Metadata - Standardized database object
7 metadata.
8
10 use Rose::DB::Object::Std::Metadata;
11
12 $meta = Rose::DB::Object::Std::Metadata->new(class => 'Product');
13 # ...or...
14 # $meta = Rose::DB::Object::Std::Metadata->for_class('Product');
15
16 $meta->table('products');
17
18 $meta->columns
19 (
20 id => { type => 'int', primary_key => 1 },
21 name => { type => 'varchar', length => 255 },
22 description => { type => 'text' },
23 category_id => { type => 'int' },
24
25 status =>
26 {
27 type => 'varchar',
28 check_in => [ 'active', 'inactive' ],
29 default => 'inactive',
30 },
31
32 start_date => { type => 'datetime' },
33 end_date => { type => 'datetime' },
34
35 date_created => { type => 'timestamp', default => 'now' },
36 last_modified => { type => 'timestamp', default => 'now' },
37 );
38
39 $meta->add_unique_key('name');
40
41 $meta->foreign_keys
42 (
43 category =>
44 {
45 class => 'Category',
46 key_columns =>
47 {
48 category_id => 'id',
49 }
50 },
51 );
52
53 ...
54
56 "Rose::DB::Object::Std::Metadata" is a subclass of
57 Rose::DB::Object::Metadata that is designed to serve the needs of
58 Rose::DB::Object::Std objects. See the Rose::DB::Object::Std
59 documentations for information on what differentiates it from
60 Rose::DB::Object.
61
62 Only the methods that are overridden are documented here. See the
63 Rose::DB::Object::Metadata documentation for the rest.
64
66 add_primary_key_column COLUMN
67 This method is an alias for the "add_primary_key_columns()" method.
68
69 add_primary_key_columns COLUMNS
70 Since Rose::DB::Object::Std objects must have a single primary key
71 column named "id", calling this method with a COLUMNS argument of
72 anything other than the column name "id" or a reference to an array
73 containing the column name "id" will cause a fatal error.
74
75 In general, you do not need to use this method at all since the
76 "primary_key_columns()" method is hard-coded to always return "id".
77
78 initialize [ARGS]
79 This method does the same thing as the Rose::DB::Object::Metadata
80 method of the same name, with one exception. If there is no column
81 named "id" in the list of columns, a scalar primary key column
82 named "id" is added to the column list. Then initialization
83 proceeds as usual.
84
85 primary_key_columns
86 Always returns the column name "id" (in list context) or a
87 reference to an array containing the column name "id" (in scalar
88 context).
89
91 John C. Siracusa (siracusa@gmail.com)
92
94 Copyright (c) 2010 by John C. Siracusa. All rights reserved. This
95 program is free software; you can redistribute it and/or modify it
96 under the same terms as Perl itself.
97
98
99
100perl v5.30.2 2020-04-06Rose::DB::Object::Std::Metadata(3)