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. type T <: DBObject

    Attributes
    abstract

Abstract Value Members

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

    Attributes
    abstract
  2. val underlying : DBCursor

    Attributes
    abstract

Concrete Value Members

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

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

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

    Attributes
    final
    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. def == (arg0: AnyRef): Boolean

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

    Attributes
    final
    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

    Examples:
    1. addSpecial( "$maxScan" , 100 )

    2. ,
    3. addSpecial( "$returnKey" , 1 )

    See also

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

  17. def asInstanceOf [T0] : T0

    Attributes
    final
    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

    See also

    size()

  23. def cursorId : Long

    cursorId

    cursorId

    returns

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

  24. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    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. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef
  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. def isInstanceOf [T0] : Boolean

    Attributes
    final
    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. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    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. def notify (): Unit

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

    Attributes
    final
    Definition Classes
    AnyRef
  41. def numGetMores : Int

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

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

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

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

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

  47. def query : DBObject

  48. def resetOptions (): Unit

    Manipulate Query Options

    Manipulate Query Options

    Resets options to default.

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  49. def sizes : Seq[Int]

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

  51. def slaveOk (): DBCursor

    slaveOk

    slaveOk

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

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

    snapshot

    snapshot

    Use snapshot mode for the query. Snapshot mode assures no duplicates are returned, or objects missed, which were present at both the start and end of the query's execution (if an object is new during the query, or deleted during the query, it may or may not be returned, even with snapshot mode).

    NOTE: Short query responses (< 1MB) are always effectively snapshotted. NOTE: Currently, snapshot mode may not be used with sorting or explicit hints.

    returns

    the same DBCursor, useful for chaining operations

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

  54. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  55. def toString (): String

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

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from Logging

Inherited from AnyRef

Inherited from Any