Yote-SQLObjectStore
view release on metacpan or search on metacpan
`ensure_path` navigates a path, creating objects along the way if they don't exist:
```perl
# Ensure a scalar value exists
$store->ensure_path( '/settings/site_name|My Site' );
# Ensure an object exists (creates it if missing)
my $bob = $store->ensure_path( '/users/bob|MyApp::User' );
# Ensure a hash exists
my $prefs = $store->ensure_path( '/users/alice/prefs|*HASH<256>_VARCHAR(256)' );
# String path format: /key|type_or_value/key|type_or_value
```
### ensure_paths
Ensure multiple paths atomically in a transaction. If any path fails, none are applied:
```perl
$store->ensure_paths(
describe.txt view on Meta::CPAN
imagine a great craigslist data tree, for storing useful things.
it is discoverable and does not need a secret handshake uuid.
my $staff = $store->fetch_path("/cl/staff/jim");
my $flag_report_prefs = $staff->fetch_path( "preferences/tools/flag_report" );
my $name = $staff->get_name;
my $columns = $flag_report_prefs->get_extra_columns;
$staff->set_quote( 'i love the list' );
$staff->rate_tool( 'flag_report', 4 );
$store->save; # saves all updates using a transaction
the getters and setters are automatically created. get_ and set_ are explicitly used
to reduce cognitive load and confusion. they are not mistaken for other methods.
it is easily defined
lib/Yote/SQLObjectStore/BaseObj.pm view on Meta::CPAN
our %cols = (
name => 'VARCHAR(100)',
bio => 'TEXT',
age => 'INTEGER',
score => 'DECIMAL(5,2)',
active => 'BOOLEAN',
avatar => '*MyApp::Image',
tags => '*ARRAY_VARCHAR(50)',
friends => '*ARRAY_*MyApp::User',
prefs => '*HASH<256>_TEXT',
);
There are two categories of column types: B<scalar types> for storing
values directly in the object's table, and B<reference types> for
storing references to other objects or to collection objects (arrays
and hashes).
=head2 Scalar Types
Scalar types use ANSI SQL standard names. Each backend automatically
( run in 1.250 second using v1.01-cache-2.11-cpan-98e64b0badf )