dataStore.Cursor

Note:

The content in this help topic pertains to SuiteScript 2.1.

Object Description

An asynchronous iterator for accessing documents retrieved by Collection.find(query).

Use for await...of to iterate through the cursor. Each yielded value is a dataStore.FindResult object.

Internally, results are retrieved in groups of up to 100 documents, with a combined document-body size of up to 10 MB per group. When you request a result beyond the current group, the cursor retrieves the next group as needed. An iteration that requires another retrieval, especially when handling larger documents, may take longer to complete.

For information about retrieving the next result, see Cursor.next(). To end iteration explicitly, see Cursor.return().

Supported Script Types

Server scripts

Module

N/dataStore Module

Methods and Properties

Cursor Object Members

Since

2026.2

Cursor Object Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Method

Cursor.next()

Promise Object

Server scripts

Returns the next iterator result.

Method

Cursor.return()

Promise Object

Server scripts

Closes the cursor and ends iteration.

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 collection = dataStore.getCollection('checkpoints');
const cursor = await collection.find({ status: 'pending' });

for await (const result of cursor) {
    const document = result.document;
    const documentId = document._id;
}

...
// Add additional code 

          

General Notices