NAME

Articulate::Content::DBIC::Simple - store your content in a simple database

DESCRIPTION

This content storage interface works by placing content and metadata in a database table, to which it connects using DBIx::Class.

All content items are stored in a single table defined in Articulate::Storage::DBIC::Simple::Schema::Result::Articulate::Item, and rows contain meta, content and location. Meta is stored in JSON.

It is left up to the application, not the database to maintain referential integrity (although there is a rudimentary cascade deletion for descendant items).

On the other hand, you can make changes to your dat structure freely without making schema changes.

By default, this will create an SQLite database in memory and deploy the schema (i.e. no persistence), but you can alter this using the schema attribute. You can also make your own schema, provided it is a superset of the existing schema.

ATTRIBUTE

schema

components:
  Articulate::Storage::DBIC::Simple:
    schema:
      class: Articulate::Storage::DBIC::Simple::Schema
      constructor: connect
      args:
        - dbi:SQLite:somefile.db
        - user_name
        - notverysecretpassword

Allows you to specify how to connect to your database. By default, it connects to an SQLite :memory: DB and uses the connect_and_deploy constructor from the Articulate::Storage::DBIC::Simple::Schema schema.

METHODS

get_item

$storage->get_item( 'zone/public/article/hello-world' )

Retrieves the metadata for the content at that location.

get_meta

$storage->get_meta( 'zone/public/article/hello-world' )

Retrieves the metadata for the content at that location.

set_meta

$storage->set_meta( 'zone/public/article/hello-world', {...} )

Sets the metadata for the content at that location.

patch_meta

$storage->patch_meta( 'zone/public/article/hello-world', {...} )

Alters the metadata for the content at that location. Existing keys are retained.

CURRENTLY this affects top-level keys only, but a descent algorigthm is planned.

get_settings

$storage->get_settings('zone/public/article/hello-world')

Retrieves the settings for the content at that location.

set_settings

$storage->set_settings('zone/public/article/hello-world', $amended_settings)

Retrieves the settings for the content at that location.

get_settings_complete

$storage->get_settings_complete('zone/public/article/hello-world')

Retrieves the settings for the content at that location.

get_content

$storage->get_content('zone/public/article/hello-world')

Retrieves the content at that location.

set_content

$storage->set_content('zone/public/article/hello-world', $blob);

Places content at that location.

create_item

$storage->create_item('zone/public/article/hello-world', $meta, $blob);

Places meta and content at that location.

item_exists

if ($storage->item_exists( 'zone/public/article/hello-world')) {
  ...
}

Determines if the item has been created (only the meta.yml is tested).

list_items

$storage->list_items ('/zone/public'); # 'hello-world', 'second-item' )

Returns a list of items in the.

empty_all_content

$storage->empty_all_content;

Removes all content. This is totally irreversible, unless you took a backup!

delete_item

$storage->delete_item ('/zone/public');

Deletes the item and all its descendants.

SEE ALSO