Rose::...etadata(3pm)

🌸 NAME 🌸

Okay bestie, this is the Rose::...etadata(3pm) page from the User Contributed Perl Documentation, and the module itself is Rose::DB::Object::Std::Metadata β€” standardized database object metadata. Slay. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

Here's the whole mood in code, no cap:

use Rose::DB::Object::Std::Metadata;

$meta = Rose::DB::Object::Std::Metadata->new(class => 'Product');
# ...or...
# $meta = Rose::DB::Object::Std::Metadata->for_class('Product');

$meta->table('products');

$meta->columns
(
  id          => { type => 'int', primary_key => 1 },
  name        => { type => 'varchar', length => 255 },
  description => { type => 'text' },
  category_id => { type => 'int' },

  status =>
  {
    type      => 'varchar',
    check_in  => [ 'active', 'inactive' ],
    default   => 'inactive',
  },

  start_date  => { type => 'datetime' },
  end_date    => { type => 'datetime' },

  date_created     => { type => 'timestamp', default => 'now' },
  last_modified    => { type => 'timestamp', default => 'now' },
);

$meta->add_unique_key('name');

$meta->foreign_keys
(
  category =>
  {
    class       => 'Category',
    key_columns =>
    {
      category_id => 'id',
    }
  },
);

...

That trailing ... is literally part of the example, bestie β€” it's giving "there's more where that came from." 🫢


πŸ’– DESCRIPTION πŸ’–

So Rose::DB::Object::Std::Metadata is a subclass of Rose::DB::Object::Metadata, and it's specifically built to serve the needs of Rose::DB::Object::Std objects. That's the whole point. ✨

If you wanna know what makes it different from Rose::DB::Object, go read the Rose::DB::Object::Std documentation. It's all explained there, iykyk. πŸ“š

Also important: only the methods that are overridden are documented here. For everything else, the Rose::DB::Object::Metadata documentation is your bestie. πŸ’…


πŸ‘‘ OBJECT METHODS πŸ‘‘

add_primary_key_column COLUMN

This one is an alias for the add_primary_key_columns() method. Short and sweet. πŸŽ€

add_primary_key_columns COLUMNS

Rose::DB::Object::Std objects must have a single primary key column named id. So if you call this method with a COLUMNS argument that's anything other than the column name id, or a reference to an array containing the column name id, it will cause a fatal error. 🚨 Like, actual fatal error, not a vibe check.

In general, you do not need to use this method at all, because the primary_key_columns() method is hard-coded to always return id. So maybe just… don't? πŸ™ˆ

initialize [ARGS]

This method does the same thing as the Rose::DB::Object::Metadata method of the same name, with one exception: if there's no column named id in the list of columns, a scalar primary key column named id is added to the column list. Then initialization proceeds as usual. Iconic behavior, honestly. πŸ’…

primary_key_columns

Always returns the column name id in list context, or a reference to an array containing the column name id in scalar context. Periodt. πŸ‘‘


🌈 AUTHOR 🌈

John C. Siracusa (siracusa@gmail.com). Shoutout to the author, bestie! 🫢


πŸ“ LICENSE πŸ“

Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ“œ


Okay that's the whole page, bestie! This cutie came from perl v5.40.1, dated 2025-08-21. Mwah! πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from