Type to use for each item. Defaults to any
.
A BatchedArrayCursor providing batch-wise access to the cursor result set.
See also BatchedArrayCursor.items.
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 more values. If set to false
, the cursor has
already been depleted and contains no more items.
Enables use with for await
to deplete the cursor by asynchronously
yielding every value 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 values in the cursor's remaining result list.
Depletes the cursor by applying the callback
function to each item in
the cursor's remaining result list. Returns an array containing the
return values of callback
for each item, 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.
Kills the cursor and frees up associated database resources.
This method has no effect if all batches have already been fetched.
Depletes the cursor by applying the callback
function to each item in
the cursor's remaining result list. Returns an array containing the
return values of callback
for each item.
Note: This creates an array of all return values, which may impact memory use when working with very large query result sets. Consider using ArrayCursor.forEach, ArrayCursor.reduce or ArrayCursor.flatMap instead.
See also:
Array.prototype.map
.
Return type of the callback
function.
Function to execute on each element.
Advances the cursor and returns the next value in the cursor's remaining
result list, 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 item in
the cursor's remaining result list. Returns the return value of reducer
for the last item.
Note: Most complex uses of the reduce
method can be replaced with
simpler code using ArrayCursor.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 item in
the cursor's remaining result list. Returns the return value of reducer
for the last item.
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
ArrayCursor
type represents a cursor returned from a Database.query.When using TypeScript, cursors can be cast to a specific item type in order to increase type safety.
See also BatchedArrayCursor.
const db = new Database(); const query = aql`FOR x IN 1..5 RETURN x`; const result = await db.query(query) as ArrayCursor<number>;
const db = new Database(); const query = aql`FOR x IN 1..10 RETURN x`; const cursor = await db.query(query); for await (const value of cursor) { // Process each value asynchronously await processValue(value); }