Trait

com.mongodb.casbah

MongoCursorBase

Related Doc: package casbah

Permalink

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

Version

2.0, 12/23/10

Since

2.0

Linear Supertypes
Logging, AnyRef, Any
Known Subclasses
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. MongoCursorBase
  2. Logging
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. abstract type T <: Imports.DBObject

    Permalink

Abstract Value Members

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

    Permalink

    _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

    Permalink

Concrete Value Members

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

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

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

    Permalink

    $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

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

    Permalink

    $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

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

    Permalink

    $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

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

    Permalink

    $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

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

    Permalink

    $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

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

    Permalink

    $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

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

    Permalink

    $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

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

    Permalink

    $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

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

    Permalink

    $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

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

    Permalink

    $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

  13. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  14. def addSpecial(name: String, o: Any): MongoCursorBase.this.type

    Permalink

    "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}

  15. final def asInstanceOf[T0]: T0

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

    Permalink

    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

  17. def clone(): AnyRef

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

    Permalink

    close

    close

    Kill the current cursor on the server

  19. def copy(): MongoCursorBase

    Permalink

    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

  20. def count(): Int

    Permalink

    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
    See also

    size()

  21. def cursorId: Long

    Permalink

    cursorId

    cursorId

    returns

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

  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: CursorExplanation

    Permalink

    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

  25. def finalize(): Unit

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

    Permalink
    Definition Classes
    AnyRef → Any
  27. def hasNext: Boolean

    Permalink

    hasNext

    hasNext

    Is there another element in the cursor?

    <invalid inheritdoc annotation>

    returns

    (Boolean Next)

  28. def hashCode(): Int

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

    Permalink

    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

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

    Permalink

    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

  31. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  32. def keysWanted: Imports.DBObject

    Permalink
  33. def limit(n: Int): MongoCursorBase.this.type

    Permalink

    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

  34. var log: Logger

    Permalink
    Attributes
    protected[com.mongodb.casbah]
    Definition Classes
    Logging
  35. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  36. def next(): T

    Permalink

    next

    next

    Iterator increment.

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

    <invalid inheritdoc annotation>

    returns

    The next element in the cursor

  37. final def notify(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  39. def numSeen: Int

    Permalink

    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

  40. def option: Int

    Permalink

    Manipulate Query Options

    Manipulate Query Options

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

    See also

    com.mongodb.Bytes

    com.mongodb.Mongo

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

    Permalink

    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

  42. def options: Int

    Permalink

    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 options_=(opts: Int): Unit

    Permalink

    Manipulate Query Options

    Manipulate Query Options

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

    See also

    com.mongodb.Bytes

    com.mongodb.Mongo

  44. def query: Imports.DBObject

    Permalink
  45. def resetOptions(): DBCursor

    Permalink

    Manipulate Query Options

    Manipulate Query Options

    Resets options to default.

    See also

    com.mongodb.Bytes

    com.mongodb.Mongo

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

    Permalink

    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

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

    Permalink

    Use snapshot mode for the query.

    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

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

    Permalink

    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

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

    Permalink
    Definition Classes
    AnyRef
  50. def toString(): String

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def slaveOk(): DBCursor

    Permalink

    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

Ungrouped