NAME

Net::Plywood::Simple - A simple interface to "Plywood", a hierarchical data storage and retrieval server

DESCRIPTION

This module is a simple wrapper around "Plywood", a hierarchical data storage and retrieval server written in Erlang. The database can be cloned from: https://github.com/ricecake/plywood The basic premise is to store, retrieve, and search for nodes in large JSON tree structures that can be merged together. Mutations can also be used to programmatically remove groups or sets of nodes from a tree.

SYNOPSIS

Storing data:

use Net::Plywood::Simple;
my $plywood = Net::Plywood::Simple->new(
	scheme => 'http',
	host   => 'localhost',
	port   => 8080,
);
my $tree_key  = 'PICKAKEY';
my $data = {...}; # build your tree
$plywood->put($tree_key, $data);

Retrieving data:

use Net::Plywood::Simple;
my $plywood = Net::Plywood::Simple->new(
	scheme => 'http',
	host   => 'localhost',
	port   => 8080,
);
my $data = $plywood->get('PICKAKEY');
## OR
my $data = $plywood->get('PICKAKEY', qw/node path in data/);

Disjoining data:

You can by key value pair present in any number of nodes programmatically "disjoin" those nodes from their parent tree:

use Net::Plywood::Simple;
my $plywood = Net::Plywood::Simple->new(
	scheme => 'http',
	host   => 'localhost',
	port   => 8080,
);
my $data = $plywood->disjoin('PICKAKEY', {key => $key, value => $value);

Any node with that key value pair given in the arguments will be removed from the tree, this is the canonical method in plywood to remove merges to trees, so you must be intentional in adding key => value pairs to your nodes so that they can be specifically selected out.

Mutate data:

Disjoin relies on mutate, and other than disjoining there are several potential actions that mutate can get you.

use Net::Plywood::Simple;
my $plywood = Net::Plywood::Simple->new(
	scheme => 'http',
	host   => 'localhost',
	port   => 8080,
);
my $data = $plywood->mutate(
	'PICKAKEY',
	{
		filter =>
		{
			field => $key,
			op    => $operator,
			value => $value,
		}
	}
);

Given a key, an operator, and a value above you can filter nodes from the tree.

The following operators are available:

>  - greater than
<  - less than
>= - greater than or equal to
=< - less than or equal to
=  - equal to
!= - not equal to

and also available are:

like
ilike
unlike
unilike

Note that these operators are based on the internal Erlang software Plywood, and have nothing to do with Perl.

AUTHOR

Shane Utt - sutt@cpan.org