Type to use for each item. Defaults to any
.
Total number of documents in the query result. Only available if the
count
option was used.
Additional information about the cursor.
Whether the cursor has any remaining batches that haven't yet been
fetched. If set to false
, all batches have been fetched and no
additional requests to the server will be made when consuming any
remaining batches from this cursor.
Whether the cursor has more batches. If set to false
, the cursor has
already been depleted and contains no more batches.
An ArrayCursor providing item-wise access to the cursor result set.
See also ArrayCursor.batches.
Enables use with for await
to deplete the cursor by asynchronously
yielding every batch in the cursor's remaining result set.
Note: If the result set spans multiple batches, any remaining batches will only be fetched on demand. Depending on the cursor's TTL and the processing speed, this may result in the server discarding the cursor before it is fully depleted.
Depletes the cursor, then returns an array containing all batches in the cursor's remaining result list.
Depletes the cursor by applying the callback
function to each batch in
the cursor's remaining result list. Returns an array containing the
return values of callback
for each batch, flattened to a depth of 1.
Note: If the result set spans multiple batches, any remaining batches will only be fetched on demand. Depending on the cursor's TTL and the processing speed, this may result in the server discarding the cursor before it is fully depleted.
See also:
Array.prototype.flatMap
.
Return type of the callback
function.
Function to execute on each element.
Advances the cursor by applying the callback
function to each item in
the cursor's remaining result list until the cursor is depleted or
callback
returns the exact value false
. Returns a promise that
evalues to true
unless the function returned false
.
Note: If the result set spans multiple batches, any remaining batches will only be fetched on demand. Depending on the cursor's TTL and the processing speed, this may result in the server discarding the cursor before it is fully depleted.
See also:
Array.prototype.forEach
.
Function to execute on each element.
Drains the cursor and frees up associated database resources.
This method has no effect if all batches have already been consumed.
Loads all remaining batches from the server.
Warning: This may impact memory use when working with very large query result sets.
Depletes the cursor by applying the callback
function to each batch in
the cursor's remaining result list. Returns an array containing the
return values of callback
for each batch.
Note: This creates an array of all return values, which may impact memory use when working with very large query result sets. Consider using BatchedArrayCursor.forEach, BatchedArrayCursor.reduce or BatchedArrayCursor.flatMap instead.
See also:
Array.prototype.map
.
Return type of the callback
function.
Function to execute on each element.
Advances the cursor and returns all remaining values in the cursor's
current batch. If the current batch has already been exhausted, fetches
the next batch from the server and returns it, or undefined
if the
cursor has been depleted.
Note: If the result set spans multiple batches, any remaining batches will only be fetched on demand. Depending on the cursor's TTL and the processing speed, this may result in the server discarding the cursor before it is fully depleted.
Depletes the cursor by applying the reducer
function to each batch in
the cursor's remaining result list. Returns the return value of reducer
for the last batch.
Note: Most complex uses of the reduce
method can be replaced with
simpler code using BatchedArrayCursor.forEach or the for await
syntax.
Note: If the result set spans multiple batches, any remaining batches will only be fetched on demand. Depending on the cursor's TTL and the processing speed, this may result in the server discarding the cursor before it is fully depleted.
See also:
Array.prototype.reduce
.
Return type of the reducer
function.
Function to execute on each element.
Initial value of the accumulator
value passed to
the reducer
function.
Depletes the cursor by applying the reducer
function to each batch in
the cursor's remaining result list. Returns the return value of reducer
for the last batch.
Note: If the result set spans multiple batches, any remaining batches will only be fetched on demand. Depending on the cursor's TTL and the processing speed, this may result in the server discarding the cursor before it is fully depleted.
See also:
Array.prototype.reduce
.
Return type of the reducer
function.
Function to execute on each element.
Generated using TypeDoc
The
BatchedArrayCursor
provides a batch-wise API to an ArrayCursor.When using TypeScript, cursors can be cast to a specific item type in order to increase type safety.
const db = new Database(); const query = aql`FOR x IN 1..5 RETURN x`; const cursor = await db.query(query) as ArrayCursor<number>; const batches = cursor.batches;
const db = new Database(); const query = aql`FOR x IN 1..10000 RETURN x`; const cursor = await db.query(query, { batchSize: 10 }); for await (const batch of cursor.batches) { // Process all values in a batch in parallel await Promise.all(batch.map( value => asyncProcessValue(value) )); }