Cursor.next()

Note:

The content in this help topic pertains to SuiteScript 2.1.

Method Description

Returns the next iterator result.

This method retrieves additional results as needed. If you call next() again before an earlier call finishes, the cursor processes the calls in order. A failure while retrieving additional results closes the cursor and rejects the Promise.

Returns

Promise Object. Resolves to an iterator result. When a result is available, its value property contains a dataStore.FindResult object.

For information about the iterator result's properties, see Using the next() Method.

Supported Script Types

Server scripts

Governance

10 units for each retrieval request. No units for calls that don't require a retrieval request.

Module

N/dataStore Module

Parent Object

dataStore.Cursor

Sibling Object Members

Cursor Object Members

Since

2026.2

Parameters

None.

Errors

Error Code

Error Message

Thrown If

DATA_STORE_NOT_ENABLED

The N/dataStore API isn't enabled for this account.

Data Store is disabled for the account.

DATA_STORE_BUNDLE_NOT_SUPPORTED

The N/dataStore API isn't supported for scripts that belong to a bundle.

The executing script belongs to a bundle.

DATA_STORE_INVALID_DOCUMENT

Data Store inputs must not contain circular references.

The query contains a circular reference when retrieving additional results.

DATA_STORE_INVALID_QUERY

Use $and or $or for logical query operations.

A query uses an unsupported logical operator.

DATA_STORE_INVALID_QUERY

Field operator objects must contain at least one operator.

A field-operator object is empty.

DATA_STORE_INVALID_QUERY

Use a number or string with ordering comparison operators.

An ordering comparison uses an incompatible operand.

DATA_STORE_INVALID_QUERY

The field operator or direct object comparison isn't supported. Use a supported operator or compare individual object properties.

A query uses an unsupported field operator or directly compares an object.

DATA_STORE_INVALID_QUERY

$exists requires true or false.

The $exists operand is not a boolean.

DATA_STORE_INVALID_QUERY

Nested $elemMatch isn't supported.

The query nests $elemMatch.

DATA_STORE_INVALID_QUERY

Field paths are limited to 32 segments and 256 UTF-8 bytes.

A complete query path exceeds either limit.

DATA_STORE_INVALID_QUERY

Use nonempty object property names in field paths. Array indexes and JSONPath syntax aren't supported.

A field path contains unsupported syntax.

DATA_STORE_INVALID_QUERY

Query string literals are limited to 4,000 UTF-8 bytes.

A string operand exceeds the byte limit.

DATA_STORE_INVALID_QUERY

Query numbers must be finite.

A numeric query operand is nonfinite.

DATA_STORE_INVALID_QUERY

Use JSON scalar values for comparisons. Objects and arrays can't be compared directly.

A direct comparison uses a nonscalar value.

DATA_STORE_INVALID_QUERY

A query predicate must be a JSON object.

A query predicate is not an object.

DATA_STORE_INVALID_QUERY

Query object keys must be strings.

A query object has a nonstring key.

DATA_STORE_INVALID_QUERY

Logical and membership operators require nonempty arrays.

A logical or membership operand is empty or is not an array.

DATA_STORE_TOO_MANY_PARAMETERS

The operation requires too many bound parameters. Simplify the query or reduce the batch size.

The operation requires more than 32,000 bound parameters, including internal parameters.

Syntax

Important:

The following code sample shows the syntax for this member. It isn't a functional example. For a complete script example, see N/dataStore Module Script Samples.

            // Add additional code
...

const cursor = await collection.find({ status: 'pending' });
const nextResult = await cursor.next();
if (!nextResult.done) {
    log.debug({ title: 'Document', details: nextResult.value.document });
}

...
// Add additional code 

          

General Notices