trait Cursor[T] extends Object with Readable
Cursor
- Annotations
- @RawJSType() @native()
- See also
https://mongodb.github.io/node-mongodb-native/api-generated/cursor.html
- Alphabetic
- By Inheritance
- Cursor
- Readable
- IEventEmitter
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
_read(size: Int): Unit
- Definition Classes
- Readable
-
def
_readableState: ReadableState
- Definition Classes
- Readable
-
def
addCursorFlag(flag: CursorFlag, value: Boolean): Cursor.this.type
Add a cursor flag to the cursor
Add a cursor flag to the cursor
- flag
The flag to set, must be one of following ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'partial'].
- value
The flag boolean value.
-
def
addListener(eventName: String, listener: Function): Cursor.this.type
- Definition Classes
- IEventEmitter
-
def
addQueryModifier(name: String, value: Boolean): Cursor.this.type
Add a query modifier to the cursor query
Add a query modifier to the cursor query
- name
The query modifier (must start with $, such as $orderby etc)
- value
The flag boolean value.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
batchSize(size: Int, callback: MongoCallback1[Cursor.this.type] = js.native): Promise[Cursor.this.type]
Sets the batch size parameter of this cursor to the given value.
Sets the batch size parameter of this cursor to the given value.
- size
the new batch size.
- callback
this optional callback will be called after executing this method. The first parameter will contain an error object when the batchSize given is not a valid number or when the cursor is already closed while the second parameter will contain a reference to this object upon successful execution.
- returns
a promise of the Cursor if the callback was not passed
batchSize(size[, callback])
Example: -
def
clone(): Cursor.this.type
Clone the cursor
Clone the cursor
- Definition Classes
- Cursor → AnyRef
-
def
close(callback: MongoCallback1[Cursor.this.type] = js.native): Promise[Cursor.this.type]
Close the cursor, sending a KillCursor command and emitting close.
Close the cursor, sending a KillCursor command and emitting close.
- callback
this will be called after executing this method. The first parameter will always contain null while the second parameter will contain a reference to this cursor.
- returns
a promise of the Cursor if the callback was not passed
-
def
collation(value: Any): Cursor.this.type
Set the collation options for the cursor.
Set the collation options for the cursor.
- value
the cursor collation options (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields).
- returns
the Cursor
-
def
comment(value: String): Cursor.this.type
Add a comment to the cursor query allowing for tracking the comment in the log.
Add a comment to the cursor query allowing for tracking the comment in the log.
- value
The comment attached to this query.
- returns
the Cursor
-
def
count(applySkipLimit: Boolean, callback: MongoCallback1[Int]): Promise[Int]
Determines how many result the query for this cursor will return
Determines how many result the query for this cursor will return
- applySkipLimit
if set to true will apply the skip and limits set on the cursor. Defaults to false.
- callback
this will be called after executing this method. The first parameter will contain the Error object if an error occurred, or null otherwise. While the second parameter will contain the number of results or null if an error occurred.
- returns
a promise of the count if the callback was not passed
count(applySkipLimit, [options], [callback])
Example: -
def
count(applySkipLimit: Boolean, options: |[CountOptions, RawOptions], callback: MongoCallback1[Int]): Promise[Int]
Determines how many result the query for this cursor will return
Determines how many result the query for this cursor will return
- applySkipLimit
if set to true will apply the skip and limits set on the cursor. Defaults to false.
- options
the optional settings.
- callback
this will be called after executing this method. The first parameter will contain the Error object if an error occurred, or null otherwise. While the second parameter will contain the number of results or null if an error occurred.
- returns
a promise of the count if the callback was not passed
count(applySkipLimit, [options], [callback])
Example: -
val
domain: String
- Definition Classes
- IEventEmitter
-
def
emit(name: String, args: Any*): Any
- Definition Classes
- IEventEmitter
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
explain(callback: Function): Unit
Gets a detailed information about how the query is performed on this cursor and how long it took the database to process it.
Gets a detailed information about how the query is performed on this cursor and how long it took the database to process it.
- callback
this will be called after executing this method. The first parameter will always be null while the second parameter will be an object containing the details.
explain(callback)
Example: -
def
filter(filter: Any): Cursor.this.type
Set the cursor query
Set the cursor query
- filter
The filter object used for the cursor.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
forEach(iterator: Function1[T, Any], callback: MongoCallback1[T]): Unit
Iterates over all the documents for this cursor using the iterator, callback pattern.
Iterates over all the documents for this cursor using the iterator, callback pattern.
- iterator
The iteration callback.
- callback
The end callback.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
getMaxListeners(): Int
- Definition Classes
- IEventEmitter
-
def
hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
hint(hint: String = js.native): Cursor.this.type
Set the cursor hint
Set the cursor hint
- hint
If specified, then the query system will only consider plans using the hinted index.
-
def
isClosed(): Boolean
Check if the cursor is closed or open.
Check if the cursor is closed or open.
- returns
the state of the cursor.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPaused(): Boolean
- Definition Classes
- Readable
-
def
isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
-
def
limit(value: Int): Cursor.this.type
Sets the limit parameter of this cursor to the given value.
Sets the limit parameter of this cursor to the given value.
- value
The limit for the cursor query.
- returns
the Cursor
-
def
listenerCount(eventName: String): Int
- Definition Classes
- IEventEmitter
-
def
listeners(eventName: String): Array[Function]
- Definition Classes
- IEventEmitter
-
def
map(transform: Function): Unit
Map all documents using the provided function
Map all documents using the provided function
- transform
The mapping transformation method.
-
def
max(max: Int): Cursor.this.type
Set the cursor max
Set the cursor max
- max
Specify a $max value to specify the exclusive upper bound for a specific index in order to constrain the results of find(). The $max specifies the upper bound for all keys of a specific index in order.
-
def
maxAwaitTimeMS(value: Int): Cursor.this.type
Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise)
Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise)
- value
Number of milliseconds to wait before aborting the tailed query.
-
def
maxScan(maxScan: Int): Cursor.this.type
Set the cursor maxScan
Set the cursor maxScan
- maxScan
Constrains the query to only scan the specified number of documents when fulfilling the query
-
def
maxTimeMS(maxTimeMS: Int, callback: Function = js.native): Cursor.this.type
Specifies a time limit for a query operation.
Specifies a time limit for a query operation. After the specified time is exceeded, the operation will be aborted and an error will be returned to the client. If maxTimeMS is null, no limit is applied.
- maxTimeMS
the maxTimeMS for the query.
- callback
this optional callback will be called after executing this method. The first parameter will contain an error object when the limit given is not a valid number or when the cursor is already closed while the second parameter will contain a reference to this object upon successful execution.
maxTimeMS(maxTimeMS[, callback])
Example: -
def
min(min: Int): Cursor.this.type
Set the cursor min
Set the cursor min
- min
Specify a $min value to specify the inclusive lower bound for a specific index in order to constrain the results of find(). The $min specifies the lower bound for all keys of a specific index in order.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
next(callback: MongoCallback1[T] = js.native): Promise[T]
Get the next available document from the cursor, returns null if no more documents are available.
Get the next available document from the cursor, returns null if no more documents are available.
- callback
The result callback.
- returns
promise if no callback passed
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
on(eventName: String, listener: Function): Cursor.this.type
- Definition Classes
- IEventEmitter
-
def
once(eventName: String, listener: Function): Cursor.this.type
- Definition Classes
- IEventEmitter
-
def
pause(): Cursor.this.type
- Definition Classes
- Readable
-
def
pipe(destination: Writable, options: |[ReadablePipeOptions, RawOptions]): Cursor.this.type
- Definition Classes
- Readable
-
def
project(value: Any): Cursor.this.type
Sets a field projection for the query.
Sets a field projection for the query.
- value
The field projection object.
-
def
propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
-
def
push(chunk: Buffer): Boolean
- Definition Classes
- Readable
-
def
push(chunk: String, encoding: String): Boolean
- Definition Classes
- Readable
-
def
read[T](size: Int): T
- Definition Classes
- Readable
-
def
removeAllListeners(): Cursor.this.type
- Definition Classes
- IEventEmitter
-
def
removeAllListeners(eventName: String): Cursor.this.type
- Definition Classes
- IEventEmitter
-
def
removeListener(eventName: String, listener: Function): Cursor.this.type
- Definition Classes
- IEventEmitter
-
def
resume(): Cursor.this.type
- Definition Classes
- Readable
-
def
returnKey(returnKey: Int): Cursor.this.type
Set the cursor returnKey
Set the cursor returnKey
- returnKey
Only return the index field or fields for the results of the query. If $returnKey is set to true and the query does not use an index to perform the read operation, the returned documents will not contain any fields.
-
def
rewind(): Cursor.this.type
Resets this cursor to its initial state.
Resets this cursor to its initial state. All settings like the query string, tailable, batchSizeValue, skipValue and limits are preserved.
-
def
setEncoding(encoding: String): Cursor.this.type
- Definition Classes
- Readable
-
def
setMaxListeners(n: Int): Cursor.this.type
- Definition Classes
- IEventEmitter
-
def
setReadPreference(readPreference: |[ReadPreference, String]): Cursor.this.type
Sets the read preference for the cursor
Sets the read preference for the cursor
- readPreference
The new read preference for the cursor.
setReadPreference(pref)
Example: -
def
showRecordId(enable: Boolean): Cursor.this.type
Set the cursor showRecordId
Set the cursor showRecordId
- enable
The $showDiskLoc option has now been deprecated and replaced with the showRecordId field. $showDiskLoc will still be accepted for OP_QUERY stye find.
- returns
the Cursor
-
def
skip(value: Int): Cursor.this.type
Set the skip for the cursor.
Set the skip for the cursor.
- value
The skip for the cursor query.
- returns
the Cursor
-
def
snapshot(enable: Boolean): Cursor.this.type
TODO document me
-
def
snapshot(snapshot: Any): Cursor.this.type
Set the cursor snapshot
Set the cursor snapshot
- snapshot
The $snapshot operator prevents the cursor from returning a document more than once because an intervening write operation results in a move of the document.
- returns
the Cursor
-
def
sort(keyOrList: |[String, Array[Any]], direction: |[Int, String]): Cursor.this.type
Sets the sort parameter of this cursor to the given value.
Sets the sort parameter of this cursor to the given value.
- keyOrList
this can be a string or an array. If passed as a string, the string will be the field to sort. If passed an array, each element will represent a field to be sorted and should be an array that contains the format [string, direction].
- direction
this determines how the results are sorted. "asc", "ascending" or 1 for ascending order while "desc", "descending or -1 for descending order. Note that the strings are case insensitive.
sort(keyOrList, direction, callback)
Example: -
def
sort(keyOrList: Array[Any], callback: Function = js.native): Cursor.this.type
Sets the sort parameter of this cursor to the given value.
Sets the sort parameter of this cursor to the given value.
- keyOrList
this can be a string or an array. If passed as a string, the string will be the field to sort. If passed an array, each element will represent a field to be sorted and should be an array that contains the format [string, direction].
- callback
this will be called after executing this method. The first parameter will contain an error object when the cursor is already closed while the second parameter will contain a reference to this object upon successful execution.
sort(keyOrList, direction, callback)
Example: -
def
sort(keyOrList: String, direction: |[Int, String], callback: Function): Cursor.this.type
Sets the sort parameter of this cursor to the given value.
Sets the sort parameter of this cursor to the given value.
- keyOrList
this can be a string or an array. If passed as a string, the string will be the field to sort. If passed an array, each element will represent a field to be sorted and should be an array that contains the format [string, direction].
- direction
this determines how the results are sorted. "asc", "ascending" or 1 for ascending order while "desc", "descending or -1 for descending order. Note that the strings are case insensitive.
- callback
this will be called after executing this method. The first parameter will contain an error object when the cursor is already closed while the second parameter will contain a reference to this object upon successful execution.
sort(keyOrList, direction, callback)
Example: -
def
stream(options: CursorStreamOptions): Cursor.this.type
Return a modified Readable stream including a possible transform method.
Return a modified Readable stream including a possible transform method.
- options
the optional settings
- returns
returns a Cursor.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toArray(callback: MongoCallback1[Array[T]] = js.native): Promise[Array[T]]
Returns an array of documents.
Returns an array of documents. The caller is responsible for making sure that there is enough memory to store the results. Note that the array only contain partial results when this cursor had been previously accessed. In that case, cursor.rewind() can be used to reset the cursor.
- callback
This will be called after executing this method successfully. The first parameter will contain the Error object if an error occurred, or null otherwise. The second parameter will contain an array of BSON deserialized objects as a result of the query.
-
def
toLocaleString(): String
- Definition Classes
- Object
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
unpipe(destination: Writable): Unit
- Definition Classes
- Readable
-
def
unshift(chunk: Any): Unit
- Definition Classes
- Readable
-
val
usingDomains: Boolean
- Definition Classes
- IEventEmitter
-
def
valueOf(): Any
- Definition Classes
- Object
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
wrap(stream: Any): Unit
- Definition Classes
- Readable
Deprecated Value Members
-
def
each(callback: MongoCallback1[T]): Unit
Iterates over all the documents for this cursor.
Iterates over all the documents for this cursor. As with {cursor.toArray}, not all of the elements will be iterated if this cursor had been previouly accessed. In that case, {cursor.rewind} can be used to reset the cursor. However, unlike {cursor.toArray}, the cursor will only hold a maximum of batch size elements at any given time if batch size is specified. Otherwise, the caller is responsible for making sure that the entire result can fit the memory.
- callback
this will be called for while iterating every document of the query result. The first parameter will contain the Error object if an error occurred, or null otherwise. While the second parameter will contain the document.
- Annotations
- @deprecated
- Deprecated
(Since version 2.2) No alternatives specified
-
def
nextObject(callback: MongoCallback1[T] = js.native): Promise[T]
Gets the next document from the cursor.
Gets the next document from the cursor.
- callback
The result callback.
- returns
promise if no callback passed
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use next() instead