Tangram::Cursor(3pm)
π Tangram::Cursor π
okay bestie, so this is Tangram::Cursor, from the Tangram::Cursor(3pm) page β it's literally the thing that lets you traverse a result set π¦
β¨ SYNOPSIS β¨
$cursor = $storage->cursor($remote, $filter);
while (my $obj = $cursor->current())
{
# process $obj
$cursor->next();
}
$cursor->execute();
while (my $obj = $cursor->current())
{
# process $obj
$cursor->next();
}
πΈ DESCRIPTION πΈ
A Cursor is that girl π she makes it possible to iterate over a result set without loading all the objects in memory. no cap, that's the whole point β she's efficient, she's lowkey iconic.
Also, go peek at the limit option to the select method of the Tangram::Storage class. iykyk π
π INSTANCE METHODS π
β current
$obj = $cursor->current();
Returns the current object, or undef() if the result set is exhausted. that's it, that's the vibe π
β next
$obj = $cursor->next();
@obj = $cursor->next();
Moves to the next object in the result set, if any. Returns the new current object, or undef() if the result set is exhausted. And in list context? it returns all the remaining objects β she's generous like that π
β execute
$cursor->execute();
Moves the cursor to the first object in the result set, and returns it. ok important tea: preparing Cursors is an expensive operation π so you should reuse them if possible β and execute() allows just that, she's giving main character energy π«Ά
execute() may be called several times in a row, or on a Cursor that has just been obtained from a Storage, without ill effects. no drama, no side quests, we love a stable queen β¨
β residue
my @vals = $cursor->residue();
Returns the values of the Expr that were passed to the retrieve directive of the Storage::select() or Storage::cursor() statement. yes bestie, the residue is where the receipts live π
π CURSORS AND CONNECTIONS π
Each Cursor opens its own connection to the database.
likeβ¦ every single one. no sharing, no borrowing, she needs her own space π§
π SEE ALSO π
Tangram::Storage
and that's the whole page, babe β this was perl v5.36.0, dated 2022-10-16 β slay, go write some cursors, you've got this ππ
π¦ where this page comes from
- ubuntu noble: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms