---
name: "Catmandu::Store::FedoraCommons"
section: "3pm"
platform: "linux"
package: "libcatmandu-fedoracommons-perl"
version: "0.5-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::Store::FedoraCommons"
---

# Catmandu::Store::FedoraCommons(3pm)

A Catmandu::Store plugin for the Fedora Commons repository

## NAME

Catmandu::Store::FedoraCommons - A Catmandu::Store plugin for the Fedora Commons repository

## SYNOPSIS

```
 use Catmandu::Store::FedoraCommons;
 my $store = Catmandu::Store::FedoraCommons->new(
         baseurl  => 'http://localhost:8080/fedora',
         username => 'fedoraAdmin',
         password => 'fedoraAdmin',
         model    => 'Catmandu::Store::FedoraCommons::DC' # default
 );
 # We use the DC model, lets store some DC
 my $obj1 = $store->bag->add({
                    title => ['The Master and Margarita'] ,
                    creator => ['Bulgakov, Mikhail'] }
            );
 printf "obj1 stored as %s\n" , $obj1->{_id};
 # Force an id in the store
 my $obj2 = $store->bag->add({ _id => 'demo:120812' , title => ['The Master and Margarita']  });
 my $obj3 = $store->bag->get('demo:120812');
 $store->bag->delete('demo:120812');
 $store->bag->delete_all;
 # All bags are iterators
 $store->bag->each(sub {
     my $obj = $_[0];
     my $pid = $obj->{_id};
     my $ds  = $store->fedora->listDatastreams(pid => $pid)->parse_content;
 });
 $store->bag->take(10)->each(sub { ... });
```

## DESCRIPTION

A Catmandu::Store::FedoraCommons is a Perl package that can store data into FedoraCommons backed databases. The database as a whole is called a 'store'. Databases also have compartments (e.g. tables) called Catmandu::Bag-s. In Fedora we have namespaces. A bag corresponds to a namespace. The default bag corresponds to the default namespace in Fedora.

By default Catmandu::Store::FedoraCommons works with a Dublin Core data model. You can use the add,get and delete methods of the store to retrieve and insert Perl HASH-es that mimic Dublin Core records. Optionally other models can be provided by creating a model package that implements a 'get' and 'update' method.

## METHODS

### new(baseurl =\> $fedora\_baseurl , username =\> $username , password =\> $password , model =\> $model )

Create a new Catmandu::Store::FedoraCommons store at `$fedora_baseurl`. Optionally provide a name of a `$model` to serialize your Perl hashes into a Fedora Commons model.

### bag('$namespace')

Create or retrieve a bag. Returns a Catmandu::Bag. Use this for storing or retrieving records from a fedora namespace.

### fedora

Returns a low level Catmandu::FedoraCommons reference.

## INHERITED METHODS

This Catmandu::Store implements:

- Catmandu::Store

  Each Catmandu::Bag in this Catmandu::Store implements:

- Catmandu::Bag

  ## SEE ALSO

Catmandu::FedoraCommons

## AUTHOR

- •

  Patrick Hochstenbach, `"<patrick.hochstenbach at ugent.be>"`
