Skip to content

@temporary-escape/mod-sdk / DocumentCursor

Class: DocumentCursor<T extends Serializable> ​

Defined in: database/document-cursor.ts:37

A document cursor that can iterate over documents in a database.

The cursor points to the first document when the cursor is created.

You MUST call the close() method when you are done with the cursor to free up resources. Not closing the cursor will result in a memory leak!!!

Extends ​

Type Parameters ​

Type Parameter
T extends Serializable

Constructors ​

Constructor ​

ts
new DocumentCursor<T extends Serializable>(handle: number, factory: () => T): DocumentCursor<T>;

Defined in: database/document-cursor.ts:38

Parameters ​

ParameterType
handlenumber
factory() => T

Returns ​

DocumentCursor<T>

Overrides ​

Cursor.constructor

Accessors ​

key ​

Get Signature ​

ts
get key(): number;

Defined in: database/document-cursor.ts:89

Returns the key of the current document

Returns zero if the cursor is not valid.

Returns ​

number

Overrides ​

Cursor.key


value ​

Get Signature ​

ts
get value(): T;

Defined in: database/document-cursor.ts:102

Returns the document

Calling this multiple times returns the same document. To advance to the next document, you must call the next() function.

Calls abort() if the cursor is not valid.

Returns ​

T

Overrides ​

Cursor.value

Methods ​

close() ​

ts
close(): void;

Defined in: database/document-cursor.ts:47

Closes the cursor

Returns ​

void

Overrides ​

Cursor.close


next() ​

ts
next(): void;

Defined in: database/document-cursor.ts:61

Advances the cursor to the next document

The cursor points to the first document when the cursor is created. You must call this function when you want to move to the next document (second or later).

You must check if the cursor is valid after calling this function.

Returns ​

void

Overrides ​

Cursor.next


seekToLast() ​

ts
seekToLast(): void;

Defined in: database/document-cursor.ts:71

Goes to the last document available in the seek range.

You must check if the cursor is valid after calling this function.

Returns ​

void


valid() ​

ts
valid(): boolean;

Defined in: database/document-cursor.ts:79

Returns true if the cursor points to some valid document

Returns ​

boolean

Overrides ​

Cursor.valid