com.mongodb.casbah

MongoCursorBase

trait MongoCursorBase extends Logging

Scala wrapper for Mongo DBCursors, including ones which return custom DBObject subclasses.

This is a rewrite of the Casbah 1.0 approach which was rather naive and unnecessarily complex.... formerly was MongoCursorWrapper

Source
MongoCursor.scala
Version

2.0, 12/23/10

Since

2.0

Linear Supertypes
Logging, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. MongoCursorBase
  2. Logging
  3. AnyRef
  4. Any
Visibility
  1. Public
  2. All

Type Members

  1. abstract type T <: DBObject

Abstract Value Members

  1. abstract def _newInstance(cursor: DBCursor): MongoCursorBase

    _newInstance

    _newInstance

    Utility method which concrete subclasses are expected to implement for creating a new instance of THIS concrete implementation from a Java cursor. Good with cursor calls that return a new cursor.

    cursor

    (DBCursor)

    returns

    (this.type)

  2. abstract val underlying: DBCursor

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def $explain(bool: Boolean = true): MongoCursorBase.this.type

    $explain

    $explain

    Sets a special operator of $explain which, if true, explains the query instead of returning results.

    This is the same as calling the explain() method on the cursor.

    bool

    (Boolean = true)

    returns

    the same DBCursor, useful for chaining operations

  5. def $hint[A](obj: A)(implicit arg0: (A) ⇒ DBObject): MongoCursorBase.this.type

    $hint

    $hint

    Sets a special operator $hint which forces the query to use a given index.

    This is the same as calling hint() on the cursor.

    obj

    (DBObject)

    returns

    the same DBCursor, useful for chaining operations

  6. def $max[A](obj: A)(implicit arg0: (A) ⇒ DBObject): MongoCursorBase.this.type

    $max

    $max

    Sets maximum index bounds - commonly paired with $max

    obj

    (DBObject)

    returns

    the same DBCursor, useful for chaining operations

    See also

    http://www.mongodb.org/display/DOCS/max+and+max+Query+Specifiers

  7. def $maxScan[A](max: T)(implicit arg0: Numeric[A]): MongoCursorBase.this.type

    $maxScan

    $maxScan

    Sets a special operator of $maxScan Which defines the max number of items to scan.

    A

    : Numeric

    max

    (A)

    returns

    the same DBCursor, useful for chaining operations

  8. def $min[A](obj: A)(implicit arg0: (A) ⇒ DBObject): MongoCursorBase.this.type

    $min

    $min

    Sets minimum index bounds - commonly paired with $max

    obj

    (DBObject)

    returns

    the same DBCursor, useful for chaining operations

    See also

    http://www.mongodb.org/display/DOCS/min+and+max+Query+Specifiers

  9. def $orderby[A](obj: A)(implicit arg0: (A) ⇒ DBObject): MongoCursorBase.this.type

    $orderby

    $orderby

    Sets a special operator of $orderby which defines the sort spec for this cursor.

    This is the same as calling sort on the cursor.

    obj

    (DBObject)

    returns

    the same DBCursor, useful for chaining operations

  10. def $query[A](q: A)(implicit arg0: (A) ⇒ DBObject): MongoCursorBase.this.type

    $query

    $query

    Sets a special operator of $query Which defines the query for this cursor.

    This is the same as running find() on a Collection with the query.

    q

    (DBObject)

    returns

    the same DBCursor, useful for chaining operations

  11. def $returnKey(bool: Boolean = true): MongoCursorBase.this.type

    $returnKey

    $returnKey

    Sets a special operator of $returnKey If true, returns ONLY the index key. Defaults to true if you just call $returnKey

    bool

    (Boolean = true)

    returns

    the same DBCursor, useful for chaining operations

  12. def $showDiskLoc(bool: Boolean = true): MongoCursorBase.this.type

    $showDiskLoc

    $showDiskLoc

    Sets a special operator $showDiskLoc which, if true, shows the disk location of results.

    bool

    (Boolean = true)

    returns

    the same DBCursor, useful for chaining operations

  13. def $snapshot(bool: Boolean = true): MongoCursorBase.this.type

    $snapshot

    $snapshot

    Sets a special operator of $snapshot which, if True, sets snapshot mode on the query.

    This is the same as calling the snapshot() method on the cursor.

    bool

    (Boolean = true)

    returns

    the same DBCursor, useful for chaining operations

  14. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  16. def addSpecial(name: String, o: Any): MongoCursorBase.this.type

    "Special" Operators for cursors

    "Special" Operators for cursors

    adds a special operator like $maxScan or $returnKey

    returns

    the same DBCursor, useful for chaining operations

    See also

    http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-Specialoperators { @inheritDoc}

  17. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  18. def batchSize(n: Int): MongoCursorBase

    batchSize

    batchSize

    Limits the number of elements returned in one batch.

    n

    (Int) The number of elements to return in a batch

    returns

    the same DBCursor, useful for chaining operations

  19. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  20. def close(): Unit

    close

    close

    Kill the current cursor on the server

  21. def copy(): MongoCursorBase

    copy

    copy

    Creates a new copy of an existing database cursor. The new cursor is an iterator even if the original was an array.

    returns

    The new cursor

  22. def count(): Int

    count

    count

    The DBCursor's count of elements in the query, passed through from the Java object. Note that Scala Iterator[_] base trait has a count method which tests predicates and you should be careful about using that.

    NOTE: count() ignores any skip/limit settings on a cursor; it is the count of the ENTIRE query results. If you want to get a count post-skip/limit you must use size()

    returns

    Int indicating the number of elements returned by the query

    Exceptions thrown
    MongoException()

    See also

    size()

  23. def cursorId: Long

    cursorId

    cursorId

    returns

    A long representing the cursorID on the server; 0 = no cursor

  24. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  26. def explain: CursorExplanation

    explain

    explain

    Returns an object containing basic information about the execution of the query that created this cursor. This creates an instance of CursorExplanation which is a custom dbObject with the key/value pairs: - cursor = Cursor Type - nscanned = Number of items examined by Mongo for this query - nscannedObjects = Number of objects examined by Mongo - n = the number of records which Mongo returned - millis = how long it took Mongo to execute the query - nYields = number of times this query yielded the read lock to let writes in - indexBounds = the index boundaries used.

    CursorExplanation provides utility methods to access these fields.

    returns

    an instance of CursorExplanation

    See also

    http://dochub.mongodb.org/core/explain

  27. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  28. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  29. def hasNext: Boolean

    hasNext

    hasNext

    Is there another element in the cursor?

    returns

    (Boolean Next)

  30. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  31. def hint(indexName: String): MongoCursorBase.this.type

    hint

    hint

    Provide the Database a hint of an indexed field of a collection to use to improve performance.

    indexName

    (String) The name of an index

    returns

    the same DBCursor, useful for chaining operations

  32. def hint[A](indexKeys: A)(implicit arg0: (A) ⇒ DBObject): MongoCursorBase.this.type

    hint

    hint

    Provide the Database a hint of which indexed fields of a collection to use to improve performance.

    A

    A view of DBObject to use for the indexKeys

    indexKeys

    (A) A DBObject of the index names as keys

    returns

    the same DBCursor, useful for chaining operations

  33. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  34. def keysWanted: DBObject

  35. def limit(n: Int): MongoCursorBase.this.type

    limit

    limit

    Limits the number of elements returned.

    NOTE: Specifying a negative number instructs the server to retrun that number of items and close the cursor. It will only return what can fit into a single 4MB response

    n

    (Int) The number of elements to return

    returns

    A cursor pointing to the first element of the limited results

    See also

    http://dochub.mongodb.org/core/limit

  36. var log: Logger

    Attributes
    protected[casbah]
    Definition Classes
    Logging
  37. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  38. def next(): T

    next

    next

    Iterator increment.

    TODO: The cast to T should be examined for sanity/safety.

    returns

    The next element in the cursor

  39. final def notify(): Unit

    Definition Classes
    AnyRef
  40. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  41. def numSeen: Int

    numSeen

    numSeen

    Returns the number of objects through which this cursor has iterated, as tracked by the java driver.

    returns

    The number of objects seen

  42. def option: Int

    Manipulate Query Options

    Manipulate Query Options

    Gets current option settings - see Bytes.QUERYOPTION_* for list

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  43. def option_=(option: Int): Unit

    Manipulate Query Options

    Manipulate Query Options

    Adds an option - see Bytes.QUERYOPTION_* for list TODO - Create Scala version of Bytes.QUERYOPTION_*

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  44. def options: Int

    Manipulate Query Options

    Manipulate Query Options

    Gets current option settings - see Bytes.QUERYOPTION_* for list

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  45. def options_=(opts: Int): Unit

    Manipulate Query Options

    Manipulate Query Options

    Sets current option settings - see Bytes.QUERYOPTION_* for list

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  46. def query: DBObject

  47. def resetOptions(): DBCursor

    Manipulate Query Options

    Manipulate Query Options

    Resets options to default.

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  48. def skip(n: Int): MongoCursorBase.this.type

    skip

    skip

    Discards a given number of elements at the beginning of the cursor.

    n

    (Int) The number of elements to skip

    returns

    A cursor pointing to the first element of the results

    See also

    http://dochub.mongodb.org/core/skip

  49. def snapshot(): MongoCursorBase.this.type

    snapshot

    snapshot

    Use snapshot mode for the query. Snapshot mode prevents the cursor from returning a document more than once because an intervening write operation results in a move of the document. Even in snapshot mode, documents inserted or deleted during the lifetime of the cursor may or may not be returned. Currently, snapshot mode may not be used with sorting or explicit hints.

    returns

    the same DBCursor, useful for chaining operations

  50. def sort[A](orderBy: A)(implicit arg0: (A) ⇒ DBObject): MongoCursorBase.this.type

    sort

    sort

    Sort this cursor's elements

    A

    A view of DBObject to sort by

    orderBy

    (A) The fields on which to sort

    returns

    A cursor pointing to the first element of the sorted results

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

    Definition Classes
    AnyRef
  52. def toString(): String

    Definition Classes
    AnyRef → Any
  53. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def numGetMores: Int

    Gets the number of times, so far, that the cursor retrieved a batch from the database

    Gets the number of times, so far, that the cursor retrieved a batch from the database

    returns

    The number of times OP_GET_MORE has been called

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

  2. def sizes: Buffer[Integer]

    Gets a list containing the number of items received in each batch

    Gets a list containing the number of items received in each batch

    returns

    a list containing the number of items received in each batch

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

  3. def slaveOk(): DBCursor

    slaveOk

    slaveOk

    Makes this query OK to run on a non-master node.

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.3.0) Replaced with ReadPreference.SECONDARY

Inherited from Logging

Inherited from AnyRef

Inherited from Any