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
- Alphabetic
- By Inheritance
- MongoCursorBase
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- abstract type T <: Imports.DBObject
Abstract Value Members
-
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)
- abstract val underlying: DBCursor
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
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
-
def
$hint[A](obj: A)(implicit arg0: (A) ⇒ Imports.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
-
def
$max[A](obj: A)(implicit arg0: (A) ⇒ Imports.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
-
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
-
def
$min[A](obj: A)(implicit arg0: (A) ⇒ Imports.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
-
def
$orderby[A](obj: A)(implicit arg0: (A) ⇒ Imports.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
-
def
$query[A](q: A)(implicit arg0: (A) ⇒ Imports.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
-
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
-
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
-
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
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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}
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
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
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
close(): Unit
close
close
Kill the current cursor on the server
-
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
-
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
- See also
size()
-
def
cursorId: Long
cursorId
cursorId
- returns
A long representing the cursorID on the server; 0 = no cursor
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hasNext: Boolean
hasNext
hasNext
Is there another element in the cursor?
<invalid inheritdoc annotation>
- returns
(Boolean Next)
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
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
-
def
hint[A](indexKeys: A)(implicit arg0: (A) ⇒ Imports.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
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def keysWanted: Imports.DBObject
-
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
-
val
log: Logger
- Attributes
- protected[com.mongodb.casbah]
- Definition Classes
- Logging
- Annotations
- @transient() @volatile()
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
next(): T
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
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
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
-
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
-
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
-
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
-
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
- def query: Imports.DBObject
-
def
resetOptions(): DBCursor
Manipulate Query Options
Manipulate Query Options
Resets options to default.
- See also
com.mongodb.Bytes
com.mongodb.Mongo
-
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
-
def
snapshot(): MongoCursorBase.this.type
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
-
def
sort[A](orderBy: A)(implicit arg0: (A) ⇒ Imports.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
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
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