Trait/Object

io.scalajs.npm.mongodb

Cursor

Related Docs: object Cursor | package mongodb

Permalink

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. var _read: Function0[Any]

    Permalink
    Definition Classes
    Readable
  5. def addCursorFlag(flag: CursorFlag, value: Boolean): Cursor.this.type

    Permalink

    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.

  6. def addListener(eventName: String, listener: Function): Cursor.this.type

    Permalink
    Definition Classes
    IEventEmitter
  7. def addQueryModifier(name: String, value: Boolean): Cursor.this.type

    Permalink

    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.

  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def batchSize(size: Int, callback: MongoCallback[Cursor.this.type]): Unit

    Permalink

    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.

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

  10. def batchSize(size: Int): Promise[Cursor.this.type]

    Permalink

    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.

    returns

    a promise of the Cursor

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

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

    Permalink

    Clone the cursor

    Clone the cursor

    Definition Classes
    Cursor → AnyRef
  12. def close(callback: MongoCallback[Cursor.this.type]): Unit

    Permalink

    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.

  13. def close(): Promise[Cursor.this.type]

    Permalink

    Close the cursor, sending a KillCursor command and emitting close.

    Close the cursor, sending a KillCursor command and emitting close.

    returns

    a promise of the Cursor

  14. def close(callback: Function): Unit

    Permalink
    Definition Classes
    Readable
  15. def collation(value: Any): Cursor.this.type

    Permalink

    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

  16. def comment(value: String): Cursor.this.type

    Permalink

    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

  17. def count(applySkipLimit: Boolean, callback: MongoCallback[Int]): Unit

    Permalink

    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.

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

  18. def count(applySkipLimit: Boolean, options: |[CountOptions, RawOptions], callback: MongoCallback[Int]): Unit

    Permalink

    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.

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

  19. def count(applySkipLimit: Boolean = js.native, options: |[CountOptions, RawOptions] = js.native): Promise[Int]

    Permalink

    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.

    returns

    a promise of the count

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

  20. var domain: String

    Permalink
    Definition Classes
    IEventEmitter
  21. def emit(name: String, args: Any*): Any

    Permalink
    Definition Classes
    IEventEmitter
  22. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  23. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  24. def explain(callback: Function): Unit

    Permalink

    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)

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

    Permalink

    Set the cursor query

    Set the cursor query

    filter

    The filter object used for the cursor.

  26. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  27. def forEach(iterator: Function1[T, Any], callback: MongoCallback[T]): Unit

    Permalink

    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.

  28. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  29. def getMaxListeners(): Int

    Permalink
    Definition Classes
    IEventEmitter
  30. def hasOwnProperty(v: String): Boolean

    Permalink
    Definition Classes
    Object
  31. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  32. def hint(hint: String = js.native): Cursor.this.type

    Permalink

    Set the cursor hint

    Set the cursor hint

    hint

    If specified, then the query system will only consider plans using the hinted index.

  33. def isClosed(): Boolean

    Permalink

    Check if the cursor is closed or open.

    Check if the cursor is closed or open.

    returns

    the state of the cursor.

  34. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  35. def isPaused(): Boolean

    Permalink
    Definition Classes
    Readable
  36. def isPrototypeOf(v: Object): Boolean

    Permalink
    Definition Classes
    Object
  37. def limit(limit: Int, callback: Function = js.native): Cursor.this.type

    Permalink

    Sets the limit parameter of this cursor to the given value.

    Sets the limit parameter of this cursor to the given value.

    limit

    the new limit.

    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. limit(limit[, callback])

  38. def listenerCount(eventName: String): Int

    Permalink
    Definition Classes
    IEventEmitter
  39. def listeners(eventName: String): Array[Function]

    Permalink
    Definition Classes
    IEventEmitter
  40. def map(transform: Function): Unit

    Permalink

    Map all documents using the provided function

    Map all documents using the provided function

    transform

    The mapping transformation method.

  41. def max(max: Int): Cursor.this.type

    Permalink

    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.

  42. def maxAwaitTimeMS(value: Int): Cursor.this.type

    Permalink

    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.

  43. def maxScan(maxScan: Int): Cursor.this.type

    Permalink

    Set the cursor maxScan

    Set the cursor maxScan

    maxScan

    Constrains the query to only scan the specified number of documents when fulfilling the query

  44. def maxTimeMS(maxTimeMS: Int, callback: Function = js.native): Cursor.this.type

    Permalink

    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])

  45. def min(min: Int): Cursor.this.type

    Permalink

    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.

  46. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  47. def next(): Promise[T]

    Permalink

    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.

    returns

    promise if no callback passed

  48. def next(callback: Function): Unit

    Permalink

    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

  49. def nextObject(callback: MongoCallback[T]): Unit

    Permalink

    Gets the next document from the cursor.

    Gets the next document from the cursor.

    callback

    The result callback.

    returns

    promise if no callback passed

  50. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  51. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  52. def on(eventName: String, listener: Function): Cursor.this.type

    Permalink
    Definition Classes
    IEventEmitter
  53. def once(eventName: String, listener: Function): Cursor.this.type

    Permalink
    Definition Classes
    IEventEmitter
  54. def pause(): Cursor.this.type

    Permalink
    Definition Classes
    Readable
  55. def pipe(destination: Writable, options: RawOptions): Cursor.this.type

    Permalink
    Definition Classes
    Readable
  56. def project(value: Any): Cursor.this.type

    Permalink

    Sets a field projection for the query.

    Sets a field projection for the query.

    value

    The field projection object.

  57. def propertyIsEnumerable(v: String): Boolean

    Permalink
    Definition Classes
    Object
  58. def push(value: Any): Cursor.this.type

    Permalink
    Definition Classes
    Readable
  59. def read[T](size: Int): T

    Permalink
    Definition Classes
    Readable
  60. def removeAllListeners(): Cursor.this.type

    Permalink
    Definition Classes
    IEventEmitter
  61. def removeAllListeners(eventName: String): Cursor.this.type

    Permalink
    Definition Classes
    IEventEmitter
  62. def removeListener(eventName: String, listener: Function): Cursor.this.type

    Permalink
    Definition Classes
    IEventEmitter
  63. def resume(): Cursor.this.type

    Permalink
    Definition Classes
    Readable
  64. def returnKey(returnKey: Int): Cursor.this.type

    Permalink

    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.

  65. def rewind(): Cursor.this.type

    Permalink

    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.

  66. def setEncoding(encoding: String): Cursor.this.type

    Permalink
    Definition Classes
    Readable
  67. def setMaxListeners(n: Int): Cursor.this.type

    Permalink
    Definition Classes
    IEventEmitter
  68. def setReadPreference(pref: String, callback: Function = js.native): Cursor.this.type

    Permalink

    Sets the read preference for the cursor

    Sets the read preference for the cursor

    pref

    read preference for the cursor, one of Server.READ_PRIMARY, Server.READ_SECONDARY, Server.READ_SECONDARY_ONLY

    callback

    this optional callback will be called after executing this method. The first parameter will contain an error object when the read preference 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. setReadPreference(pref[, callback])

  69. def showRecordId(enable: Boolean): Cursor.this.type

    Permalink

    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.

  70. def skip(skip: Int, callback: Function = js.native): Cursor.this.type

    Permalink

    Sets the skip parameter of this cursor to the given value.

    Sets the skip parameter of this cursor to the given value.

    skip

    the new skip value.

    callback

    this optional callback will be called after executing this method. The first parameter will contain an error object when the skip value 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. skip(skip[, callback])

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

    Permalink

    TODO document me

  72. def sort(keyOrList: |[String, Array[Any]], direction: |[Int, String]): Cursor.this.type

    Permalink

    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)

  73. def sort(keyOrList: Array[Any], callback: Function = js.native): Cursor.this.type

    Permalink

    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)

  74. def sort(keyOrList: String, direction: |[Int, String], callback: Function): Cursor.this.type

    Permalink

    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)

  75. def stream(transform: StreamTransform): Cursor.this.type

    Permalink

    Returns a Node Transform Stream interface for this cursor.

    Returns a Node Transform Stream interface for this cursor.

    returns

    returns a stream object.

  76. def stream(): CursorStream

    Permalink

    Returns a Node Transform Stream interface for this cursor.

    Returns a Node Transform Stream interface for this cursor.

    var stream = collection.find({mykey:{$ne:2}}).stream();
    stream.on("data", function(item) {});
    stream.on("end", function() {});
    returns

    returns a stream object.

  77. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  78. def toArray(callback: MongoCallback[Array[T]]): Unit

    Permalink

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

  79. def toLocaleString(): String

    Permalink
    Definition Classes
    Object
  80. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  81. def unpipe(destination: Writable): Unit

    Permalink
    Definition Classes
    Readable
  82. def unshift(chunk: Any): Unit

    Permalink
    Definition Classes
    Readable
  83. var usingDomains: Boolean

    Permalink
    Definition Classes
    IEventEmitter
  84. def valueOf(): Any

    Permalink
    Definition Classes
    Object
  85. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  86. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  87. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  88. def wrap(stream: Any): Unit

    Permalink
    Definition Classes
    Readable

Deprecated Value Members

  1. def each(callback: MongoCallback[T]): Unit

    Permalink

    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(): Promise[T]

    Permalink

    Gets the next document from the cursor.

    Gets the next document from the cursor.

    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