An open API service indexing awesome lists of open source software.

https://github.com/bluefeet/aws-dynamodb-attributeconversion

Adjust Perl data structures to be compatible with AWS' DynamoDB API.
https://github.com/bluefeet/aws-dynamodb-attributeconversion

in-development perl5

Last synced: 17 days ago
JSON representation

Adjust Perl data structures to be compatible with AWS' DynamoDB API.

Awesome Lists containing this project

README

          

=pod

=head1 NAME

AWS::DynamoDB::ItemTransformer - Convert Perl data structures to and
from AWS DynamoDB item attributes.

=head1 SYNOPSIS

use AWS::DynamoDB::ItemTransformer;

my %ddb_item = encode_ddb_item( foo => 32 );
my %item = decode_ddb_item( foo => { N => '32' } );

my $ddb_value = encode_ddb_value( 32 );
my $value = decode_ddb_value( { N => '32' } );

# Or, using the OO interface:
my $item_transformer = AWS::DynamoDB::ItemTransformer->new();

my %ddb_item = $item_transformer->encode_item( foo => 32 );
my %item = $item_transformer->decode_item( foo => { N => 32 } );

my $ddb_value = $item_transformer->encode_value( 32 );
my $value = $item_transformer->decode_value( { N => 32 } );

=head1 DESCRIPTION

DynamoDB items have an explicit data type syntax. This module makes
it easy to convert plain scalars, arrays, and hashes into the structure
that is needed to store your data in, and retrieve your data from, DynamoDB.

More information can be found at
L.

This module has both a functional interface, which provides the default
feature set, as well as an OO interface which allows for the use
of plugins to provide advanced functionality.

=head1 PLUGINS

At this time available plugins include:

=over

=item *

L

=item *

L

=item *

L

=back

=head1 DATA TYPES

Perl does not have native data types for all the data types which DynamoDB
supports. Due to this some "dumbing down" of the data types happen when
they are thawed. For example, these:

{ B=>'a' },
{ BS=>['a','b','c'] },
{ BOOL=>1 },
{ SS=>['a','b','c'] },

all encode to:

'a',
['a', 'b', 'c'],
1,
['a', 'b', 'c'],

and will decode back to:

{ S=>'a' },
{ L=>['a','b','c'] },
{ N=>1 },
{ L=>['a','b','c'] },

Alternatively you can use various plugins to alter this behavior, such
as L which adds support for
encoding and decoding L objects as the C data type.

=head1 EXPORTED

=head2 encode_ddb_item

my %ddb_item = encode_ddb_item( foo => 32 );
# foo => { N => '32' }

Take a hash of key value pairs and returns a hash with the values
passed through L. The returned hash is usually
used with the C API.

=head2 decode_ddb_item

my %item = decode_ddb_item( foo => {N => '32'} );
# foo => 32

Takes an item hash, usually returned by the C API, and
returns a new hash with the item values passed through
L.

=head2 encode_ddb_value

my $ddb_value = encode_ddb_value( 32 );
# { N => '32' }

Takes a plain scalar, hashref, or arrayref, and returns a new data
structure marked up and ready to be sent to AWS (usually to the
C API).

=head2 decode_ddb_value

my $value = decode_ddb_value( {N => '32'} );
# 32

Takes an AWS attribute value hash ref and returns the equivalent
Perl data structure.

=head1 METHODS

=head2 encode_item

This is the OO equivalent of L.

=head2 decode_item

This is the OO equivalent of L.

=head2 encode_value

This is the OO equivalent of L.

=head2 decode_value

This is the OO equivalent of L.

=head2 is_numeric

Returns true if the passed scalar is numeric. Whether a scalar
is numeric is determined by looking at the SV flags for the scalar.

This is used by L to determine if a non-ref value is
a string (S) or number (N).

=head1 AUTHOR

Aran Clary Deltac gmail.com>

=head1 ACKNOWLEDGEMENTS

Thanks to L
for encouraging their employees to contribute back to the open
source ecosystem. Without their dedication to quality software
development this distribution would not exist.

=head1 LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut