Nicolas Steenlant > Catmandu-0.5004 > Catmandu::Store

Download:
Catmandu-0.5004.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source   Latest Release: Catmandu-0.9204

NAME ^

Catmandu::Store - Namespace for packages that can make data persistent

SYNOPSIS ^

    use Catmandu::Store::DBI;

    my $store = Catmandu::Store::DBI->new(data_source => 'DBI:mysql:database=test');

    my $obj1 = $store->bag->add({ name => 'Patrick' });

    printf "obj1 stored as %s\n" , $obj1->{_id};

    # Force an id in the store
    my $obj2 = $store->bag->add({ _id => 'test123' , name => 'Nicolas' });

    my $obj3 = $store->bag->get('test123');

    $store->bag->delete('test123');

    $store->bag->delete_all;

    # Some stores can be searched
    my $hits = $store->bag->search(query => 'name:Patrick');

DESCRIPTION ^

A Catmandu::Store is a stub for Perl packages that can store data into databases or search engines. The database as a whole is called a 'store'. Databases also have compartments (e.g. tables) called Catmandu::Bag-s. Some stores can be searched using Catmandu::Searchable methods.

METHODS ^

new(%store_args, bag_class => $class, bags => { $bagname => \%bag_args })

Create a new Catmandu::Store. Optionally provide the class name of a sub-class of Catmandu::Bag. Startup parameters can be provided for each $bagname using the 'bags' parameter. E.g.

 my $store = Catmandu::Store::Hash->new(
                bags => {myBag => {plugins => ['Datestamps']}});

 # $store->bag('myBag') will now contain Datestamps
 
 my $bag_class = "Catmandu::Store::Hash::Bag"
 my $store = Catmandu::Store::Hash->new(
                bag_class => $bag_class->with_plugins('Datestamps')
             );
 
 # All $store->bag(...)'s will now contain Datestamps

bag($name)

Create or retieve a bag with name $name. Returns a Catmandu::Bag.

log

Return the current logger.

SEE ALSO ^

Catmandu::Bag, Catmandu::Searchable

syntax highlighting: