Abstract
Protected
constructorInternal
Should not be instantiated directly.
Optional
mapping: ((doc) => T)Private
Internal
_bufferPrivate
Internal
_consumedOptional
Readonly
Internal
_mappingProtected
Internal
_nextReadonly
Internal
_optionsProtected
Internal
_stateThis temporary error-ing property exists for migration convenience, and will be removed in a future version.
.bufferedCount()
has been renamed to simply be .buffered()
.This temporary error-ing property exists for migration convenience, and will be removed in a future version.
.readBufferedDocuments()
has been renamed to be .consumeBuffer()
.The current status of the cursor.
An async iterator that lazily iterates over all records in the cursor.
Note that there'll only be partial results if the cursor has been previously iterated over. You may use FindCursor.rewind to reset the cursor.
If the cursor is uninitialized, it will be initialized. If the cursor is closed, this method will return immediately.
It will close the cursor when iteration is complete, even if it was broken early.
for await (const doc of cursor) {
console.log(doc);
}
Private
_iteratorProtected
_nextProtected
Abstract
_nextProtected
Abstract
_tmThe number of raw records in the buffer.
Unless the cursor was closed before the buffer was completely read, the total number of records retrieved from the server is equal to (FindCursor.consumed + FindCursor.buffered).
Abstract
cloneCloses the cursor. The cursor will be unusable after this method is called, or until FindCursor.rewind is called.
Consumes up to max
records from the buffer, or all records if max
is not provided.
Note that this actually consumes the buffer; it doesn't just peek at it.
Optional
max: numberThe maximum number of records to read from the buffer. If not provided, all records will be read.
The records read from the buffer.
The number of records that have been read be the user from the cursor.
Unless the cursor was closed before the buffer was completely read, the total number of records retrieved from the server is equal to (FindCursor.consumed + FindCursor.buffered).
Iterates over all records in the cursor, calling the provided consumer for each record.
If the consumer returns false
, iteration will stop.
Note that there'll only be partial results if the cursor has been previously iterated over. You may use FindCursor.rewind to reset the cursor.
If the cursor is uninitialized, it will be initialized. If the cursor is closed, this method will return immediately.
It will close the cursor when iteration is complete, even if it was stopped early.
The consumer to call for each record.
A promise that resolves when iteration is complete.
If you get an IDE error "Promise returned from forEach argument is ignored", it is a known WebStorm bug.
Abstract
mapFetches the next record from the cursor. Returns null
if there are no more records to fetch.
If the cursor is uninitialized, it will be initialized. If the cursor is closed, this method will return null
.
The next record, or null
if there are no more records.
Rewinds the cursor to its uninitialized state, clearing the buffer and any state.
Any configuration set on the cursor will remain, but iteration will start from the beginning, sending new queries to the server, even if the resultant data was already fetched by this cursor.
Returns an array of all matching records in the cursor. The user should ensure that there is enough memory to store all records in the cursor.
Note that there'll only be partial results if the cursor has been previously iterated over. You may use FindCursor.rewind to reset the cursor.
If the cursor is uninitialized, it will be initialized. If the cursor is closed, this method will return an empty array.
An array of all records in the cursor.
Overview
Represents some lazy, abstract iterable cursor over any arbitrary data, which may or may not be paginated.
Shouldn't be directly instantiated, but rather spawned via Collection.findAndRerank/Collection.find, or their Table alternatives.
Typing
For most intents and purposes, you may treat the cursor as if it is typed simply as
Cursor<T>
.If you're using a projection, it is heavily recommended to provide an explicit type representing the type of the document after projection.
In full, the cursor is typed as
FindCursor<T, TRaw>
, whereT
is the type of the mapped records, andTRaw
is the type of the raw records before any mapping.If no mapping function is provided,
T
andTRaw
will be the same type. Mapping is done using the FindCursor.map method.See