_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.
(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 collection. Good with calls that return a new collection.
(DBCollection)
(this.type)
The underlying Java Mongo Driver Collection object we proxy.
Save an object to the Collection
Save an object to the Collection
object to save to the collection
Remove a matching object from the collection
Remove a matching object from the collection
object to remove from the collection
Manipulate Network Options
Manipulate Network Options
com.mongodb.Bytes
com.mongodb.Mongo
performs an aggregation operation
performs an aggregation operation
the aggregation pipeline
the aggregation options
The readPreference for the aggregation
The aggregation operation's result set
performs an aggregation operation
performs an aggregation operation
the aggregation pipeline
The readPreference for the aggregation
The aggregation operation's result set
performs an aggregation operation
performs an aggregation operation
the aggregation pipeline
the aggregation options
The aggregation operation's result set
performs an aggregation operation
performs an aggregation operation
the aggregation pipeline
The aggregation operation's result set
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
Which is equilalent toDBCollection users = mongo.getCollection( "wiki" ).getCollection( "users" );
DBCollection users = mongo.getCollection( "wiki.users" );
the name of the collection to find
the matching collection TODO - Make this support type construction
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.
a document that contains pairs with the name of the field or fields to index and order of the index
an identifier for the index. If null or empty, the default name will be used.
if the index should be unique
MongoException
if the operation failed
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.
a document that contains pairs with the name of the field or fields to index and order of the index
an identifier for the index. If null or empty, the default name will be used.
MongoException
if the operation failed
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 of field to index on
MongoException
if the operation failed
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.
a document that contains pairs with the name of the field or fields to index and order of the index
a document that controls the creation of the index.
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.
an object with a key set of the fields desired for the index
Returns the database this collection is a member of.
Returns the database this collection is a member of.
this collection's database
Find distinct values for a key
Find distinct values for a key
The DBObject type
the key to find the distinct values for
the query (optional)
the com.mongodb.ReadPreference for the operation.
Drops (deletes) this collection
Drops (deletes) this collection
Drops all indices from this collection
Checks if this collection is equal to another object.
Checks if this collection is equal to another object.
object with which to compare this collection
if the two collections are the same object
Return the explain plan for the aggregation pipeline.
Return the explain plan for the aggregation pipeline.
the aggregation pipeline to explain
the options to apply to the aggregation
the command result. The explain output may change from release to release, so best to simply log this.
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);
object for which to search
fields to return
a cursor to iterate over results
Queries for an object in this collection.
Queries for an object in this collection.
object for which to search
an iterator over the results
Queries for all objects in this collection.
Queries for all objects in this collection.
a cursor which will iterate over every object
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
query to match
fields to be returned
sort to apply before picking first document
if true, document found will be removed
update to apply
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
do upsert (insert if document not present)
whether to bypass document validation.
the maximum duration that the server will allow this operation to execute before killing it
the write concern to apply to this operation
3.1.0
MongoException
if the operation failed for some other reason
WriteConcernException
if the write failed due some other failure specific to the update command
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
query to match
fields to be returned
sort to apply before picking first document
if true, document found will be removed
update to apply
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
do upsert (insert if document not present)
whether to bypass document validation.
the maximum duration that the server will allow this operation to execute before killing it
3.1.0
MongoException
if the operation failed for some other reason
WriteConcernException
if the write failed due some other failure specific to the update command
bypassDocumentValidation requires MongoDB 3.2 or greater
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
query to match
fields to be returned
sort to apply before picking first document
if true, document found will be removed
update to apply
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
do upsert (insert if document not present)
the maximum duration that the server will allow this operation to execute before killing it
the write concern to apply to this operation
3.1.0
MongoException
if the operation failed for some other reason
WriteConcernException
if the write failed due some other failure specific to the update command
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
query to match
fields to be returned
sort to apply before picking first document
if true, document found will be removed
update to apply
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
do upsert (insert if document not present)
the maximum duration that the server will allow this operation to execute before killing it
the document as it was before the modifications, unless returnNew
is true, in which case it returns the document
after the changes were made
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.
specifies the selection criteria for the modification
a subset of fields to return
determines which document the operation will modify if the query selects multiple documents
when true, removes the selected document
the modifications to apply
when true, returns the modified document rather than the original
when true, operation creates a new document if the query returns no documents
the write concern to apply to this operation
the document as it was before the modifications, unless returnNew
is true, in which case it returns the document
after the changes were made
3.1.0
MongoException
if the operation failed for some other reason
WriteConcernException
if the write failed due some other failure specific to the update command
Finds the first document in the query and updates it.
Finds the first document in the query and updates it.
query to match
fields to be returned
sort to apply before picking first document
if true, document found will be removed
update to apply
if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
do upsert (insert if document not present)
the document as it was before the modifications, unless returnNew
is true, in which case it returns the document
after the changes were made
Finds the first document in the query (sorted) and updates it.
Finds the first document in the query (sorted) and updates it.
query to match
sort to apply before picking first document
update to apply
the old document
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 to match
update to apply
(Option[T]) of the the found document (before, or after the update)
Finds the first document in the query and removes it.
Finds the first document in the query and removes it.
the removed document
Returns a single object from this collection matching the query.
Returns a single object from this collection matching the query.
the query object
(optional) fields to return
(optional) a document whose fields specify the attributes on which to sort the result set.
(optional)
(optional) the maximum duration that the server will allow this operation to execute before killing it
(Option[T]) Some() of the object found, or None
if no such object exists
Returns a single object from this collection.
Returns a single object from this collection.
(Option[T]) Some() of the object found, or None
if this collection is empty
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.
the id to match
fields to return
(Option[T]) Some() of the object found, or None
if no such object exists
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.
the id to match
(Option[T]) Some() of the object found, or None
if no such object exists
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.
the name of this collection
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
Which is equilalent toDBCollection users = mongo.getCollection( "wiki" ).getCollection( "users" );
DBCollection users = mongo.getCollection( "wiki.users" );
the name of the collection to find
the matching collection TODO - Make this support type construction
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
specifies the selection criteria
this is ignored
limit the count to this value
number of documents to skip
The [ReadPreference] to be used for this operation
the maximum duration that the server will allow this operation to execute before killing it
the number of documents that matches selection criteria
Returns the database this collection is a member of.
Returns the database this collection is a member of.
this collection's database
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.
the name of this collection
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
list of index documents
Gets the default class for objects in the collection
Gets the default class for objects in the collection
the class
Manipulate Network Options
Manipulate Network Options
com.mongodb.Bytes
com.mongodb.Mongo
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.
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.
http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/
WriteConcern
Applies a group operation
Applies a group operation
the key to group { a : true }
optional condition on query
initial value for first match on a key
javascript reduce function
An optional function that can operate on the result(s) of the reduce function.
ReadPreferences for this command
The results of the group
Set hint fields for this collection.
Set hint fields for this collection.
a list of DBObject
s to be used as hints
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
list of index documents
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.
the builder
2.7
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.
the builder
2.7
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
the insertOptions
array of documents (<% DBObject) to save
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
array of documents (<% DBObject) to save TODO - Wrapper for 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
array of documents (<% DBObject) to save
the WriteConcern for the insert
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
the MapReduceCommand
mapReduce execute a mapReduce against this collection.
mapReduce execute a mapReduce against this collection.
the map function (JSFunction is just a type alias for String)
the reduce function (JSFunction is just a type alias for String)
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.
(optional) the selection criteria for the documents input to the map function.
(optional) the input documents, useful for optimization.
(optional) the maximum number of documents to return from the collection before map reduce
(optional) the finalize function (JSFunction is just a type alias for String)
(optional) global variables that are accessible in the map, reduce and finalize functions
(optional) include the timing information in the result information
(optional) the maximum duration that the server will allow this operation to execute before killing it
Gets the default class for objects in the collection
Gets the default class for objects in the collection
the class
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 current T
(DBObject if you have a generic collection)
A Subtype of DBObject
(Class[A])
Manipulate Network Options
Manipulate Network Options
com.mongodb.Bytes
com.mongodb.Mongo
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.
the parallel scan options
a list of cursors, whose size may be less than the number requested
2.7
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.
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.
Read Preference to use
Removes objects from the database collection.
Removes objects from the database collection.
the object that documents to be removed must match
WriteConcern for this operation TODO - Wrapper for WriteResult?
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.
new collection name (not a full namespace)
if a collection with the new name exists, whether or not to drop it
the new collection
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.
new collection name (not a full namespace)
the new collection
Manipulate Network Options
Manipulate Network Options
com.mongodb.Bytes
com.mongodb.Mongo
Saves an object to this collection.
Saves an object to this collection.
the DBObject
to save
will add _id
field to o if needed
TODO - Wrapper for WriteResult?
Set hint fields for this collection.
Set hint fields for this collection.
a list of DBObject
s to be used as hints
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 current T
(DBObject if you have a generic collection)
A Subtype of DBObject TODO - Ensure proper subtype return
(Class[A])
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.
Read Preference to use
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.
(WriteConcern) The write concern to use
http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/
WriteConcern
Performs an update operation.
Performs an update operation.
search query for old object to update
object with which to update q
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.
http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/
WriteConcern
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.
(WriteConcern) The write concern to use
http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/
WriteConcern
performs an aggregation operation
performs an aggregation operation
the aggregation pipeline
The aggregation operation's result set
(Since version 2.7) Use aggregate(List(DBObject) instead
Finds an object.
Finds an object.
query used to search
the fields of matching objects to return
will not return the first numToSkip matches
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
the objects, if found
(Since version 2.7) Use find().skip().batchSize()
.
Sets queries to be OK to run on slave nodes.
Sets queries to be OK to run on slave nodes.
(Since version 2.3.0) Replaced with ReadPreference.SECONDARY
Perform a multi update
Perform a multi update
search query for old object to update
object with which to update q
(Since version 2.3.0) In the face of default arguments this is a bit silly. Please use update(multi=True)
.
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
2.0, 12/23/10
1.0