|
|
| |
DR::Tarantool::Spaces(3) |
User Contributed Perl Documentation |
DR::Tarantool::Spaces(3) |
DR::Tarantool::Spaces - Tarantool schema description
use DR::Tarantool::Spaces;
my $s = new DR::Tarantool::Spaces({
1 => {
name => 'users', # space name
default_type => 'STR', # undescribed fields
fields => [
qw(login password role),
{
name => 'counter',
type => 'NUM'
},
{
name => 'something',
type => 'UTF8STR',
},
{
name => 'opts',
type => 'JSON',
}
],
indexes => {
0 => 'login',
1 => [ qw(login password) ],
2 => {
name => 'my_idx',
fields => 'login',
},
3 => {
name => 'my_idx2',
fields => [ 'counter', 'something' ]
}
}
},
0 => {
...
}
});
my $f = $s->pack_field('users', 'counter', 10);
my $f = $s->pack_field('users', 3, 10); # the same
my $f = $s->pack_field(1, 3, 10); # the same
my $ts = $s->pack_keys([1,2,3] => 'my_idx');
my $t = $s->pack_primary_key([1,2,3]);
The package describes all spaces used in an application. It supports the
following field types:
- NUM, NUM64, STR
- The standard Tarantool <http://tarantool.org> types.
- UTF8STR
- The same as STR, but the string is utf8-decoded after it's received
from the server.
- INT & INT64
- The same as NUM and NUM64, but contain signed values.
- JSON
- The field is encoded with JSON::XS when putting into a database, and
decoded after is received back from the server.
my $spaces = DR::Tarantool::Spaces->new( $spaces );
Return space object by number or name.
my $space = $spaces->space('name');
my $space = $spaces->space(0);
Return space number by its name.
Packs one field into a format suitable for making a database request:
my $field = $spaces->pack_field('space', 'field', $data);
Unpack one field after getting it from the server:
my $field = $spaces->unpack_field('space', 'field', $data);
Pack a tuple before making database request.
my $t = $spaces->pack_tuple('space', [ 1, 2, 3 ]);
Unpack a tuple after getting it from the database:
my $t = $spaces->unpack_tuple('space', \@fields);
constructor
use DR::Tarantool::Spaces;
my $space = DR::Tarantool::Space->new($no, $space);
Create (or return) a class to hold tuple data. The class is a descendant of
DR::Tarantool::Tuple. Returns a unique class (package) name. If a package with
such name is already exists, the method doesn't recreate it.
Return field index by field name.
Return index of the first element that is not described in the space.
Pack a field before making a database request.
Unpack a single field in a server response.
Pack a tuple to the binary protocol format:
Unpack a tuple in a server response.
returns index number by its name.
returns index name by its number.
Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org>
Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru>
This program is free software, you can redistribute it and/or
modify it under the terms of the Artistic License.
The project is placed git repo on github:
<https://github.com/dr-co/dr-tarantool/>.
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc. |