trait MongoCollectionBase extends Logging
Scala wrapper for Mongo DBCollections, including ones which return custom DBObject subclasses via setObjectClass and the like. Provides any non-parameterized methods and the basic structure. Requires an underlying object of a DBCollection.
This is a rewrite of the Casbah 1.0 approach which was rather naive and unecessarily complex.... formerly was MongoCollectionWrapper
- Self Type
- MongoCollectionBase
- Version
2.0, 12/23/10
- Since
1.0
- Alphabetic
- By Inheritance
- MongoCollectionBase
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
_newCursor(cursor: DBCursor): CursorType
_newCursor
_newCursor
Utility method which concrete subclasses are expected to implement for creating a new instance of the correct cursor implementation from a Java cursor. Good with cursor calls that return a new cursor. Should figure out the right type to return based on typing setup.
- cursor
(DBCursor)
- returns
(MongoCursorBase)
-
abstract
def
_newInstance(collection: DBCollection): MongoCollectionBase
_newInstance
_newInstance
Utility method which concrete subclasses are expected to implement for creating a new instance of THIS concrete implementation from a Java collection. Good with calls that return a new collection.
- collection
(DBCollection)
- returns
(this.type)
-
abstract
def
underlying: DBCollection
The underlying Java Mongo Driver Collection object we proxy.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+=[A](x: A)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): TypeImports.WriteResult
Save an object to the Collection
Save an object to the Collection
- x
object to save to the collection
-
def
-=[A](x: A)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): TypeImports.WriteResult
Remove a matching object from the collection
Remove a matching object from the collection
- x
object to remove from the collection
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
_typedValue(dbObj: commons.TypeImports.DBObject): Option[T]
- Attributes
- protected
-
def
addOption(option: Int): Unit
Manipulate Network Options
Manipulate Network Options
- See also
com.mongodb.Bytes
com.mongodb.Mongo
-
def
aggregate[A](pipeline: Iterable[A], options: AggregationOptions, readPreference: ReadPreference)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Cursor
performs an aggregation operation
performs an aggregation operation
- pipeline
the aggregation pipeline
- options
the aggregation options
- readPreference
The readPreference for the aggregation
- returns
The aggregation operation's result set
-
def
aggregate[A](pipeline: Iterable[A], readPreference: ReadPreference)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): AggregationOutput
performs an aggregation operation
performs an aggregation operation
- pipeline
the aggregation pipeline
- readPreference
The readPreference for the aggregation
- returns
The aggregation operation's result set
-
def
aggregate[A](pipeline: Iterable[A], options: AggregationOptions)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Cursor
performs an aggregation operation
performs an aggregation operation
- pipeline
the aggregation pipeline
- options
the aggregation options
- returns
The aggregation operation's result set
-
def
aggregate[A](pipeline: Iterable[A])(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): AggregationOutput
performs an aggregation operation
performs an aggregation operation
- pipeline
the aggregation pipeline
- returns
The aggregation operation's result set
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
collection(n: String): MongoCollection
Find a collection that is prefixed with this collection's name.
Find a collection that is prefixed with this collection's name. A typical use of this might be
DBCollection users = mongo.getCollection( "wiki" ).getCollection( "users" );
DBCollection users = mongo.getCollection( "wiki.users" );
- n
the name of the collection to find
- returns
the matching collection TODO - Make this support type construction
- def count[A, B](query: A = MongoDBObject.empty, fields: B = MongoDBObject.empty, limit: Long = 0, skip: Long = 0, readPrefs: ReadPreference = getReadPreference, maxTime: Duration = Duration(0, MILLISECONDS))(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject): Int
-
def
createIndex[A](keys: A, name: String, unique: Boolean)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Unit
Forces creation of an index on a set of fields, if one does not already exist.
Forces creation of an index on a set of fields, if one does not already exist.
- keys
a document that contains pairs with the name of the field or fields to index and order of the index
- name
an identifier for the index. If null or empty, the default name will be used.
- unique
if the index should be unique
- Exceptions thrown
MongoException
if the operation failed
-
def
createIndex[A](keys: A, name: String)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Unit
Forces creation of an index on a set of fields, if one does not already exist.
Forces creation of an index on a set of fields, if one does not already exist.
- keys
a document that contains pairs with the name of the field or fields to index and order of the index
- name
an identifier for the index. If null or empty, the default name will be used.
- Exceptions thrown
MongoException
if the operation failed
-
def
createIndex(name: String): Unit
Forces creation of an ascending index on a field with the default options.
Forces creation of an ascending index on a field with the default options.
- name
name of field to index on
- Exceptions thrown
MongoException
if the operation failed
-
def
createIndex[A, B](keys: A, options: B)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject): Unit
Creates an index on the field specified, if that index does not already exist.
Creates an index on the field specified, if that index does not already exist.
- keys
a document that contains pairs with the name of the field or fields to index and order of the index
- options
a document that controls the creation of the index.
-
def
createIndex[A](keys: A)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Unit
Forces creation of an index on a set of fields, if one does not already exist.
Forces creation of an index on a set of fields, if one does not already exist.
- keys
an object with a key set of the fields desired for the index
- def customDecoderFactory: Option[DBDecoderFactory]
- def customEncoderFactory: Option[DBEncoderFactory]
-
implicit
val
db: MongoDB
Returns the database this collection is a member of.
Returns the database this collection is a member of.
- returns
this collection's database
-
def
distinct[A](key: String, query: A = MongoDBObject.empty, readPrefs: ReadPreference = getReadPreference)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Buffer[_]
Find distinct values for a key
Find distinct values for a key
- A
The DBObject type
- key
the key to find the distinct values for
- query
the query (optional)
- readPrefs
the com.mongodb.ReadPreference for the operation.
-
def
drop(): Unit
Drops (deletes) this collection
-
def
dropCollection(): Unit
Drops (deletes) this collection
- def dropIndex(name: String): Unit
- def dropIndex[A](keys: A)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Unit
- def dropIndexes(name: String): Unit
-
def
dropIndexes(): Unit
Drops all indices from this collection
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(obj: Any): Boolean
Checks if this collection is equal to another object.
Checks if this collection is equal to another object.
- obj
object with which to compare this collection
- returns
if the two collections are the same object
- Definition Classes
- MongoCollectionBase → AnyRef → Any
-
def
explainAggregate[A](pipeline: Iterable[A], options: AggregationOptions)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Map[String, AnyRef]
Return the explain plan for the aggregation pipeline.
Return the explain plan for the aggregation pipeline.
- pipeline
the aggregation pipeline to explain
- options
the options to apply to the aggregation
- returns
the command result. The explain output may change from release to release, so best to simply log this.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
find[A, B](ref: A, keys: B)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject): CursorType
Queries for an object in this collection.
Queries for an object in this collection.
An empty DBObject will match every document in the collection. Regardless of fields specified, the _id fields are always returned.
An example that returns the "x" and "_id" fields for every document in the collection that has an "x" field:
BasicDBObject keys = new BasicDBObject(); keys.put("x", 1); DBCursor cursor = collection.find(new BasicDBObject(), keys);
- ref
object for which to search
- keys
fields to return
- returns
a cursor to iterate over results
-
def
find[A](ref: A)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): CursorType
Queries for an object in this collection.
Queries for an object in this collection.
- ref
object for which to search
- returns
an iterator over the results
-
def
find(): CursorType
Queries for all objects in this collection.
Queries for all objects in this collection.
- returns
a cursor which will iterate over every object
-
def
findAndModify[A, B, C, D](query: A, fields: B, sort: C, remove: Boolean, update: D, returnNew: Boolean, upsert: Boolean, bypassDocumentValidation: Boolean, maxTime: Duration, writeConcern: WriteConcern)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject, arg3: (D) ⇒ commons.TypeImports.DBObject): Option[T]
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
- query
query to match
- fields
fields to be returned
- sort
sort to apply before picking first document
- remove
if true, document found will be removed
- update
update to apply
- returnNew
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
- upsert
do upsert (insert if document not present)
- bypassDocumentValidation
whether to bypass document validation.
- maxTime
the maximum duration that the server will allow this operation to execute before killing it
- writeConcern
the write concern to apply to this operation
- Since
3.1.0
- Exceptions thrown
MongoException
if the operation failed for some other reasonWriteConcernException
if the write failed due some other failure specific to the update command
-
def
findAndModify[A, B, C, D](query: A, fields: B, sort: C, remove: Boolean, update: D, returnNew: Boolean, upsert: Boolean, bypassDocumentValidation: Boolean, maxTime: Duration)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject, arg3: (D) ⇒ commons.TypeImports.DBObject): Option[T]
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
- query
query to match
- fields
fields to be returned
- sort
sort to apply before picking first document
- remove
if true, document found will be removed
- update
update to apply
- returnNew
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
- upsert
do upsert (insert if document not present)
- bypassDocumentValidation
whether to bypass document validation.
- maxTime
the maximum duration that the server will allow this operation to execute before killing it
- Since
3.1.0
- Exceptions thrown
MongoException
if the operation failed for some other reasonWriteConcernException
if the write failed due some other failure specific to the update command- Note
bypassDocumentValidation requires MongoDB 3.2 or greater
-
def
findAndModify[A, B, C, D](query: A, fields: B, sort: C, remove: Boolean, update: D, returnNew: Boolean, upsert: Boolean, maxTime: Duration, writeConcern: WriteConcern)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject, arg3: (D) ⇒ commons.TypeImports.DBObject): Option[T]
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
- query
query to match
- fields
fields to be returned
- sort
sort to apply before picking first document
- remove
if true, document found will be removed
- update
update to apply
- returnNew
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
- upsert
do upsert (insert if document not present)
- maxTime
the maximum duration that the server will allow this operation to execute before killing it
- writeConcern
the write concern to apply to this operation
- Since
3.1.0
- Exceptions thrown
MongoException
if the operation failed for some other reasonWriteConcernException
if the write failed due some other failure specific to the update command
-
def
findAndModify[A, B, C, D](query: A, fields: B, sort: C, remove: Boolean, update: D, returnNew: Boolean, upsert: Boolean, maxTime: Duration)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject, arg3: (D) ⇒ commons.TypeImports.DBObject): Option[T]
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
- query
query to match
- fields
fields to be returned
- sort
sort to apply before picking first document
- remove
if true, document found will be removed
- update
update to apply
- returnNew
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
- upsert
do upsert (insert if document not present)
- maxTime
the maximum duration that the server will allow this operation to execute before killing it
- returns
the document as it was before the modifications, unless
returnNew
is true, in which case it returns the document after the changes were made
-
def
findAndModify[A, B, C, D](query: A, fields: B, sort: C, remove: Boolean, update: D, returnNew: Boolean, upsert: Boolean, writeConcern: WriteConcern)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject, arg3: (D) ⇒ commons.TypeImports.DBObject): Option[T]
Atomically modify and return a single document.
Atomically modify and return a single document. By default, the returned document does not include the modifications made on the update.
- query
specifies the selection criteria for the modification
- fields
a subset of fields to return
- sort
determines which document the operation will modify if the query selects multiple documents
- remove
when true, removes the selected document
- update
the modifications to apply
- returnNew
when true, returns the modified document rather than the original
- upsert
when true, operation creates a new document if the query returns no documents
- writeConcern
the write concern to apply to this operation
- returns
the document as it was before the modifications, unless
returnNew
is true, in which case it returns the document after the changes were made
- Since
3.1.0
- Exceptions thrown
MongoException
if the operation failed for some other reasonWriteConcernException
if the write failed due some other failure specific to the update command
-
def
findAndModify[A, B, C, D](query: A, fields: B, sort: C, remove: Boolean, update: D, returnNew: Boolean, upsert: Boolean)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject, arg3: (D) ⇒ commons.TypeImports.DBObject): Option[T]
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
- query
query to match
- fields
fields to be returned
- sort
sort to apply before picking first document
- remove
if true, document found will be removed
- update
update to apply
- returnNew
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
- upsert
do upsert (insert if document not present)
- returns
the document as it was before the modifications, unless
returnNew
is true, in which case it returns the document after the changes were made
-
def
findAndModify[A, B, C](query: A, sort: B, update: C)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject): Option[T]
Finds the first document in the query (sorted) and updates it.
Finds the first document in the query (sorted) and updates it.
- query
query to match
- sort
sort to apply before picking first document
- update
update to apply
- returns
the old document
-
def
findAndModify[A, B](query: A, update: B)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject): Option[T]
Finds the first document in the query (sorted) and updates it.
Finds the first document in the query (sorted) and updates it. If remove is specified it will be removed. If new is specified then the updated document will be returned, otherwise the old document is returned (or it would be lost forever). You can also specify the fields to return in the document, optionally.
- query
query to match
- update
update to apply
- returns
(Option[T]) of the the found document (before, or after the update)
-
def
findAndRemove[A](query: A)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Option[T]
Finds the first document in the query and removes it.
Finds the first document in the query and removes it.
- returns
the removed document
-
def
findOne[A, B, C](o: A = MongoDBObject.empty, fields: B = MongoDBObject.empty, orderBy: C = MongoDBObject.empty, readPrefs: ReadPreference = getReadPreference, maxTime: Duration = Duration(0, MILLISECONDS))(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject): Option[T]
Returns a single object from this collection matching the query.
Returns a single object from this collection matching the query.
- o
the query object
- fields
(optional) fields to return
- orderBy
(optional) a document whose fields specify the attributes on which to sort the result set.
- readPrefs
(optional)
- maxTime
(optional) the maximum duration that the server will allow this operation to execute before killing it
- returns
(Option[T]) Some() of the object found, or
None
if no such object exists
-
def
findOne(): Option[T]
Returns a single object from this collection.
Returns a single object from this collection.
- returns
(Option[T]) Some() of the object found, or
None
if this collection is empty
-
def
findOneByID[B](id: AnyRef, fields: B)(implicit arg0: (B) ⇒ commons.TypeImports.DBObject): Option[T]
Find an object by its ID.
Find an object by its ID. Finds an object by its id. This compares the passed in value to the _id field of the document.
Returns a single object from this collection matching the query.
- id
the id to match
- fields
fields to return
- returns
(Option[T]) Some() of the object found, or
None
if no such object exists
-
def
findOneByID(id: AnyRef): Option[T]
Find an object by its ID.
Find an object by its ID. Finds an object by its id. This compares the passed in value to the _id field of the document.
Returns a single object from this collection matching the query.
- id
the id to match
- returns
(Option[T]) Some() of the object found, or
None
if no such object exists
-
def
fullName: String
Returns the full name of this collection, with the database name as a prefix.
Returns the full name of this collection, with the database name as a prefix.
- returns
the name of this collection
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
getCollection(n: String): MongoCollection
Find a collection that is prefixed with this collection's name.
Find a collection that is prefixed with this collection's name. A typical use of this might be
DBCollection users = mongo.getCollection( "wiki" ).getCollection( "users" );
DBCollection users = mongo.getCollection( "wiki.users" );
- n
the name of the collection to find
- returns
the matching collection TODO - Make this support type construction
-
def
getCount[A, B](query: A = MongoDBObject.empty, fields: B = MongoDBObject.empty, limit: Long = 0, skip: Long = 0, readPrefs: ReadPreference = getReadPreference, maxTime: Duration = Duration(0, MILLISECONDS))(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject): Int
Returns the number of documents in the collection that match the specified query
Returns the number of documents in the collection that match the specified query
- query
specifies the selection criteria
- fields
this is ignored
- limit
limit the count to this value
- skip
number of documents to skip
- readPrefs
The [ReadPreference] to be used for this operation
- maxTime
the maximum duration that the server will allow this operation to execute before killing it
- returns
the number of documents that matches selection criteria
-
def
getDB: MongoDB
Returns the database this collection is a member of.
Returns the database this collection is a member of.
- returns
this collection's database
-
def
getFullName: String
Returns the full name of this collection, with the database name as a prefix.
Returns the full name of this collection, with the database name as a prefix.
- returns
the name of this collection
-
def
getIndexInfo: Buffer[commons.TypeImports.DBObject]
Return a list of the indexes for this collection.
Return a list of the indexes for this collection. Each object in the list is the "info document" from MongoDB
- returns
list of index documents
- def getName: String
-
def
getObjectClass: Class[_]
Gets the default class for objects in the collection
Gets the default class for objects in the collection
- returns
the class
-
def
getOptions: Int
Manipulate Network Options
Manipulate Network Options
- See also
com.mongodb.Bytes
com.mongodb.Mongo
-
def
getReadPreference: ReadPreference
Gets the read preference for this collection.
Gets the read preference for this collection. Will be used as default for reads from any collection in this collection. See the documentation for com.mongodb.casbah.ReadPreference for more information.
- def getStats: CommandResult
-
def
getWriteConcern: WriteConcern
get the write concern for this database, which is used for writes to any collection in this database.
get the write concern for this database, which is used for writes to any collection in this database. See the documentation for com.mongodb.WriteConcern for more info.
- See also
http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/
WriteConcern
-
def
group[A, B, C](key: A, cond: B, initial: C, reduce: String, finalize: String = null, readPrefs: ReadPreference = getReadPreference)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject, arg2: (C) ⇒ commons.TypeImports.DBObject): Iterable[T]
Applies a group operation
Applies a group operation
- key
the key to group
{ a : true }
- cond
optional condition on query
- initial
initial value for first match on a key
- reduce
javascript reduce function
- finalize
An optional function that can operate on the result(s) of the reduce function.
- readPrefs
ReadPreferences for this command
- returns
The results of the group
-
def
hashCode(): Int
- Definition Classes
- MongoCollectionBase → AnyRef → Any
-
def
hintFields_=[A](docs: List[A])(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Unit
Set hint fields for this collection.
Set hint fields for this collection.
- docs
a list of
DBObject
s to be used as hints
-
def
indexInfo: Buffer[commons.TypeImports.DBObject]
Return a list of the indexes for this collection.
Return a list of the indexes for this collection. Each object in the list is the "info document" from MongoDB
- returns
list of index documents
-
def
initializeOrderedBulkOperation: BulkWriteOperation
Creates a builder for an ordered bulk operation.
Creates a builder for an ordered bulk operation. Write requests included in the bulk operations will be executed in order, and will halt on the first failure.
- returns
the builder
- Since
2.7
-
def
initializeUnorderedBulkOperation: BulkWriteOperation
Creates a builder for an unordered bulk operation.
Creates a builder for an unordered bulk operation. Write requests included in the bulk operation will be executed in an undefined order, and all requests will be executed even if some fail.
- returns
the builder
- Since
2.7
-
def
insert[A](insertOptions: InsertOptions, docs: A*)(implicit dbObjView: (A) ⇒ commons.TypeImports.DBObject): TypeImports.WriteResult
Saves document(s) to the database.
Saves document(s) to the database. if doc doesn't have an _id, one will be added you can get the _id that was added from doc after the insert
- insertOptions
the insertOptions
- docs
array of documents (<% DBObject) to save
-
def
insert[A](docs: A*)(implicit dbObjView: (A) ⇒ commons.TypeImports.DBObject, concern: WriteConcern = writeConcern, encoder: TypeImports.DBEncoder = ...): TypeImports.WriteResult
Saves document(s) to the database.
Saves document(s) to the database. if doc doesn't have an _id, one will be added you can get the _id that was added from doc after the insert
- docs
array of documents (<% DBObject) to save TODO - Wrapper for WriteResult?
-
def
insert[A](doc: A, concern: WriteConcern)(implicit dbObjView: (A) ⇒ commons.TypeImports.DBObject): TypeImports.WriteResult
Saves document(s) to the database.
Saves document(s) to the database. if doc doesn't have an _id, one will be added you can get the _id that was added from doc after the insert
- doc
array of documents (<% DBObject) to save
- concern
the WriteConcern for the insert
- def internalClass_=[A <: commons.TypeImports.DBObject](path: String, c: Class[A]): Unit
- def isCapped: Boolean
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def iterator: CursorType
-
val
log: Logger
- Attributes
- protected[com.mongodb.casbah]
- Definition Classes
- Logging
- Annotations
- @transient() @volatile()
-
def
mapReduce(cmd: map_reduce.MapReduceCommand): MapReduceResult
mapReduce execute a mapReduce against this collection.
mapReduce execute a mapReduce against this collection.
Throws a MongoExecutionTimeoutException if exceeds max duration limit otherwise returns a MapReduceResult
- cmd
the MapReduceCommand
-
def
mapReduce(mapFunction: Imports.JSFunction, reduceFunction: Imports.JSFunction, output: Imports.MapReduceOutputTarget, query: Option[commons.TypeImports.DBObject] = None, sort: Option[commons.TypeImports.DBObject] = None, limit: Option[Int] = None, finalizeFunction: Option[Imports.JSFunction] = None, jsScope: Option[commons.TypeImports.DBObject] = None, verbose: Boolean = false, maxTime: Option[Duration] = None): MapReduceResult
mapReduce execute a mapReduce against this collection.
mapReduce execute a mapReduce against this collection.
- mapFunction
the map function (JSFunction is just a type alias for String)
- reduceFunction
the reduce function (JSFunction is just a type alias for String)
- output
the location of the result of the map-reduce operation, defaults to inline. You can output to a collection, output to a collection with an action, or output inline.
- query
(optional) the selection criteria for the documents input to the map function.
- sort
(optional) the input documents, useful for optimization.
- limit
(optional) the maximum number of documents to return from the collection before map reduce
- finalizeFunction
(optional) the finalize function (JSFunction is just a type alias for String)
- jsScope
(optional) global variables that are accessible in the map, reduce and finalize functions
- verbose
(optional) include the timing information in the result information
- maxTime
(optional) the maximum duration that the server will allow this operation to execute before killing it
- def name: String
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
objectClass: Class[_]
Gets the default class for objects in the collection
Gets the default class for objects in the collection
- returns
the class
-
def
objectClass_=[A <: commons.TypeImports.DBObject](c: Class[A])(implicit arg0: Manifest[A]): MongoGenericTypedCollection[A]
setObjectClass
setObjectClass
Set a subtype of DBObject which will be used to deserialize documents returned from MongoDB.
This method will return a new
MongoTypedCollection[A]
which you should capture if you want explicit casting. Else, this collection will instantiate instances of A but cast them to the currentT
(DBObject if you have a generic collection)- A
A Subtype of DBObject
- c
(Class[A])
-
def
options: Int
Manipulate Network Options
Manipulate Network Options
- See also
com.mongodb.Bytes
com.mongodb.Mongo
-
def
parallelScan(options: ParallelScanOptions): Buffer[Cursor]
Return a list of cursors over the collection that can be used to scan it in parallel.
Return a list of cursors over the collection that can be used to scan it in parallel.
Note: As of MongoDB 2.6, this method will work against a mongod, but not a mongos.
- options
the parallel scan options
- returns
a list of cursors, whose size may be less than the number requested
- Since
2.7
-
def
readPreference: ReadPreference
Gets the read preference for this collection.
Gets the read preference for this collection. Will be used as default for reads from any collection in this collection. See the documentation for com.mongodb.casbah.ReadPreference for more information.
-
def
readPreference_=(pref: ReadPreference): Unit
Sets the read preference for this collection.
Sets the read preference for this collection. Will be used as default for reads from any collection in this collection. See the documentation for com.mongodb.casbah.ReadPreference for more information.
- pref
Read Preference to use
-
def
remove[A](o: A, concern: WriteConcern = getWriteConcern)(implicit dbObjView: (A) ⇒ commons.TypeImports.DBObject, encoder: TypeImports.DBEncoder = ...): TypeImports.WriteResult
Removes objects from the database collection.
Removes objects from the database collection.
- o
the object that documents to be removed must match
- concern
WriteConcern for this operation TODO - Wrapper for WriteResult?
-
def
rename(newName: String, dropTarget: Boolean): MongoCollection
does a rename of this collection to newName As per the Java API this returns a *NEW* Collection, and the old collection is probably no good anymore.
does a rename of this collection to newName As per the Java API this returns a *NEW* Collection, and the old collection is probably no good anymore.
This collection *WILL NOT* mutate --- the instance will still point at a now nonexistant collection with the old name ... You must capture the return value for the new instance.
- newName
new collection name (not a full namespace)
- dropTarget
if a collection with the new name exists, whether or not to drop it
- returns
the new collection
-
def
rename(newName: String): MongoCollection
does a rename of this collection to newName As per the Java API this returns a *NEW* Collection, and the old collection is probably no good anymore.
does a rename of this collection to newName As per the Java API this returns a *NEW* Collection, and the old collection is probably no good anymore.
This collection *WILL NOT* mutate --- the instance will still point at a now nonexistant collection with the old name ... You must capture the return value for the new instance.
- newName
new collection name (not a full namespace)
- returns
the new collection
-
def
resetOptions(): Unit
Manipulate Network Options
Manipulate Network Options
- See also
com.mongodb.Bytes
com.mongodb.Mongo
-
def
save[A](o: A, concern: WriteConcern = getWriteConcern)(implicit dbObjView: (A) ⇒ commons.TypeImports.DBObject): TypeImports.WriteResult
Saves an object to this collection.
Saves an object to this collection.
- o
the
DBObject
to save will add_id
field to o if needed TODO - Wrapper for WriteResult?
-
def
setHintFields[A](docs: List[A])(implicit arg0: (A) ⇒ commons.TypeImports.DBObject): Unit
Set hint fields for this collection.
Set hint fields for this collection.
- docs
a list of
DBObject
s to be used as hints
- def setInternalClass[A <: commons.TypeImports.DBObject](path: String, c: Class[A]): Unit
-
def
setObjectClass[A <: commons.TypeImports.DBObject](c: Class[A])(implicit arg0: Manifest[A]): MongoGenericTypedCollection[A]
setObjectClass
setObjectClass
Set a subtype of DBObject which will be used to deserialize documents returned from MongoDB.
This method will return a new
MongoTypedCollection[A]
which you should capture if you want explicit casting. Else, this collection will instantiate instances of A but cast them to the currentT
(DBObject if you have a generic collection)- A
A Subtype of DBObject TODO - Ensure proper subtype return
- c
(Class[A])
-
def
setReadPreference(pref: ReadPreference): Unit
Sets the read preference for this collection.
Sets the read preference for this collection. Will be used as default for reads from any collection in this collection. See the documentation for com.mongodb.casbah.ReadPreference for more information.
- pref
Read Preference to use
-
def
setWriteConcern(concern: WriteConcern): Unit
Set the write concern for this database.
Set the write concern for this database. Will be used for writes to any collection in this database. See the documentation for com.mongodb.WriteConcern for more info.
- concern
(WriteConcern) The write concern to use
- See also
http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/
WriteConcern
- def stats: CommandResult
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- MongoCollectionBase → AnyRef → Any
-
def
update[A, B](q: A, o: B, upsert: Boolean = false, multi: Boolean = false, concern: WriteConcern = this.writeConcern, bypassDocumentValidation: Option[Boolean] = None)(implicit queryView: (A) ⇒ commons.TypeImports.DBObject, objView: (B) ⇒ commons.TypeImports.DBObject, encoder: TypeImports.DBEncoder = ...): TypeImports.WriteResult
Performs an update operation.
Performs an update operation.
- q
search query for old object to update
- o
object with which to update
q
-
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( ... )
-
def
writeConcern: WriteConcern
get the write concern for this database, which is used for writes to any collection in this database.
get the write concern for this database, which is used for writes to any collection in this database. See the documentation for com.mongodb.WriteConcern for more info.
- See also
http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/
WriteConcern
-
def
writeConcern_=(concern: WriteConcern): Unit
Set the write concern for this database.
Set the write concern for this database. Will be used for writes to any collection in this database. See the documentation for com.mongodb.WriteConcern for more info.
- concern
(WriteConcern) The write concern to use
- See also
http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/
WriteConcern
Deprecated Value Members
-
def
aggregate(pipeline: commons.TypeImports.DBObject*): AggregationOutput
performs an aggregation operation
performs an aggregation operation
- pipeline
the aggregation pipeline
- returns
The aggregation operation's result set
- Annotations
- @deprecated
- Deprecated
(Since version 2.7) Use aggregate(List(DBObject) instead
-
def
find[A, B](ref: A, fields: B, numToSkip: Int, batchSize: Int)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject): CursorType
Finds an object.
Finds an object.
- ref
query used to search
- fields
the fields of matching objects to return
- numToSkip
will not return the first numToSkip matches
- batchSize
if positive, is the # of objects per batch sent back from the db. All objects that match will be returned. if batchSize < 0, its a hard limit, and only 1 batch will either batchSize or the # that fit in a batch
- returns
the objects, if found
- Annotations
- @deprecated
- Deprecated
(Since version 2.7) Use
find().skip().batchSize()
.
-
def
slaveOk(): Unit
Sets queries to be OK to run on slave nodes.
Sets queries to be OK to run on slave nodes.
- Annotations
- @deprecated @SuppressWarnings()
- Deprecated
(Since version 2.3.0) Replaced with
ReadPreference.SECONDARY
-
def
updateMulti[A, B](q: A, o: B)(implicit arg0: (A) ⇒ commons.TypeImports.DBObject, arg1: (B) ⇒ commons.TypeImports.DBObject): TypeImports.WriteResult
Perform a multi update
Perform a multi update
- q
search query for old object to update
- o
object with which to update q
- Annotations
- @deprecated
- Deprecated
(Since version 2.3.0) In the face of default arguments this is a bit silly. Please use
update(multi=True)
.