The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Zing::Cursor - Lookup Table Traversal

ABSTRACT

Lookup Table Traversal Construct

SYNOPSIS

use Zing::Lookup;
use Zing::Cursor;

my $lookup = Zing::Lookup->new(name => 'users');

$lookup->set('user-12345')->set(username => 'u12345');
$lookup->set('user-12346')->set(username => 'u12346');
$lookup->set('user-12347')->set(username => 'u12347');

my $cursor = Zing::Cursor->new(lookup => $lookup);

# $cursor->count;

DESCRIPTION

This package provides a cursor for traversing Zing::Lookup indices and supports forward and backwards traversal as well as token-based pagination.

LIBRARIES

This package uses type constraints from:

Zing::Types

ATTRIBUTES

This package has the following attributes:

lookup

lookup(Lookup)

This attribute is read-only, accepts (Lookup) values, and is required.

position

position(Maybe[Str])

This attribute is read-write, accepts (Maybe[Str]) values, and is optional.

METHODS

This package implements the following methods:

count

count() : Int

The count method returns the number of Zing::Domain objects in the lookup table.

count example #1
# given: synopsis

$cursor->count;

fetch

fetch(Int $size = 1) : ArrayRef[Domain]

The fetch method returns the next n Zing::Domain objects from the lookup table.

fetch example #1
# given: synopsis

$cursor->fetch;
fetch example #2
# given: synopsis

$cursor->fetch(5);

first

first() : Maybe[Domain]

The first method returns the first Zing::Domain object created in the lookup table.

first example #1
# given: synopsis

$cursor->first;

last

last() : Maybe[Domain]

The last method returns the last Zing::Domain object created in the lookup table.

last example #1
# given: synopsis

$cursor->last;

next

next() : Maybe[Domain]

The next method returns the next (after the current position) Zing::Domain object in the lookup table.

next example #1
# given: synopsis

$cursor->next;
next example #2
# given: synopsis

$cursor->next;
$cursor->next;

prev

prev() : Maybe[Domain]

The prev method returns the prev (before the current position) Zing::Domain object in the lookup table.

prev example #1
# given: synopsis

$cursor->prev;
prev example #2
# given: synopsis

$cursor->prev;
$cursor->prev;

reset

reset() : Cursor

The reset method returns the cursor to its starting position (defined at construction).

reset example #1
# given: synopsis

$cursor->prev;
$cursor->next;
$cursor->next;

$cursor->reset;

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues