trait Cursor[T] extends Object with Readable

Cursor

Annotations
@RawJSType() @native()
See also

https://mongodb.github.io/node-mongodb-native/api-generated/cursor.html
Linear Supertypes
Readable, IEventEmitter, Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Cursor
  2. Readable
  3. IEventEmitter
  4. Object
  5. Any
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def _read(size: Int): Unit
    Definition Classes
    Readable
  5. def _readableState: ReadableState
    Definition Classes
    Readable
  6. 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.

  7. def addListener(eventName: String, listener: Function): Cursor.this.type
    Definition Classes
    IEventEmitter
  8. 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.

  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. 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

    Example:
    1. batchSize(size[, callback])

  11. def clone(): Cursor.this.type

    Clone the cursor

    Clone the cursor

    Definition Classes
    Cursor → AnyRef
  12. 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

  13. 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

  14. 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

  15. 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

    Example:
    1. count(applySkipLimit, [options], [callback])

  16. 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

    Example:
    1. count(applySkipLimit, [options], [callback])

  17. val domain: String
    Definition Classes
    IEventEmitter
  18. def emit(name: String, args: Any*): Any
    Definition Classes
    IEventEmitter
  19. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  21. 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.

    Example:
    1. explain(callback)

  22. def filter(filter: Any): Cursor.this.type

    Set the cursor query

    Set the cursor query

    filter

    The filter object used for the cursor.

  23. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  24. 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.

  25. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  26. def getMaxListeners(): Int
    Definition Classes
    IEventEmitter
  27. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  28. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  29. 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.

  30. 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.

  31. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  32. def isPaused(): Boolean
    Definition Classes
    Readable
  33. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  34. 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

  35. def listenerCount(eventName: String): Int
    Definition Classes
    IEventEmitter
  36. def listeners(eventName: String): Array[Function]
    Definition Classes
    IEventEmitter
  37. def map(transform: Function): Unit

    Map all documents using the provided function

    Map all documents using the provided function

    transform

    The mapping transformation method.

  38. 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.

  39. 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.

  40. 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

  41. 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.

    Example:
    1. maxTimeMS(maxTimeMS[, callback])

  42. 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.

  43. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. 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

  45. final def notify(): Unit
    Definition Classes
    AnyRef
  46. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  47. def on(eventName: String, listener: Function): Cursor.this.type
    Definition Classes
    IEventEmitter
  48. def once(eventName: String, listener: Function): Cursor.this.type
    Definition Classes
    IEventEmitter
  49. def pause(): Cursor.this.type
    Definition Classes
    Readable
  50. def pipe(destination: Writable, options: |[ReadablePipeOptions, RawOptions]): Cursor.this.type
    Definition Classes
    Readable
  51. 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.

  52. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  53. def push(chunk: Buffer): Boolean
    Definition Classes
    Readable
  54. def push(chunk: String, encoding: String): Boolean
    Definition Classes
    Readable
  55. def read[T](size: Int): T
    Definition Classes
    Readable
  56. def removeAllListeners(): Cursor.this.type
    Definition Classes
    IEventEmitter
  57. def removeAllListeners(eventName: String): Cursor.this.type
    Definition Classes
    IEventEmitter
  58. def removeListener(eventName: String, listener: Function): Cursor.this.type
    Definition Classes
    IEventEmitter
  59. def resume(): Cursor.this.type
    Definition Classes
    Readable
  60. 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.

  61. 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.

  62. def setEncoding(encoding: String): Cursor.this.type
    Definition Classes
    Readable
  63. def setMaxListeners(n: Int): Cursor.this.type
    Definition Classes
    IEventEmitter
  64. 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.

    Example:
    1. setReadPreference(pref)

  65. 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

  66. 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

  67. def snapshot(enable: Boolean): Cursor.this.type

    TODO document me

  68. 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

  69. 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.

    Example:
    1. sort(keyOrList, direction, callback)

  70. 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.

    Example:
    1. sort(keyOrList, direction, callback)

  71. 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.

    Example:
    1. sort(keyOrList, direction, callback)

  72. 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.

  73. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  74. 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.

  75. def toLocaleString(): String
    Definition Classes
    Object
  76. def toString(): String
    Definition Classes
    AnyRef → Any
  77. def unpipe(destination: Writable): Unit
    Definition Classes
    Readable
  78. def unshift(chunk: Any): Unit
    Definition Classes
    Readable
  79. val usingDomains: Boolean
    Definition Classes
    IEventEmitter
  80. def valueOf(): Any
    Definition Classes
    Object
  81. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  82. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  83. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  84. def wrap(stream: Any): Unit
    Definition Classes
    Readable

Deprecated Value Members

  1. 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

  2. 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

Inherited from Readable

Inherited from IEventEmitter

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped