Cursor.return()

Note:

The content in this help topic pertains to SuiteScript 2.1.

Method Description

Closes the cursor and ends iteration.

After you call this method, subsequent next() calls indicate that iteration is complete. Exiting a for await...of loop early, such as by using break, automatically calls this method.

Returns

Promise Object. Resolves to a completed iterator result.

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

Supported Script Types

Server scripts

Governance

None

Module

N/dataStore Module

Parent Object

dataStore.Cursor

Sibling Object Members

Cursor Object Members

Since

2026.2

Parameters

None.

Errors

None.

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 first = await cursor.next();
await cursor.return();

...
// Add additional code 

          

General Notices