_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.
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)
the maximum duration that the server will allow this operation to execute before killing it
the old document
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 old document
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
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
Adds the "private" fields _id to an object.
Adds the "private" fields _id to an object.
object to which to add fields
whether to add an _id
field or not
the modified object o
(Since version 2.8) This will be removed in a future release
Adds the "private" fields _id to an object.
Adds the "private" fields _id to an object.
DBObject
to which to add fields
the modified parameter object
(Since version 2.8) This will be removed in a future release
Ensures an index on this collection (that is, the index will be created if it does not exist).
Ensures an index on this collection (that is, the index will be created if it does not exist). ensureIndex is optimized and is inexpensive if the index already exists. This creates an ascending index on a particular field.
an identifier for the index
(Since version 2.8) Use createIndex instead
Ensures an optionally unique index on this collection.
Ensures an optionally unique index on this collection.
fields to use for index
an identifier for the index
if the index should be unique
(Since version 2.8) Use createIndex instead
Ensures an index on this collection (that is, the index will be created if it does not exist).
Ensures an index on this collection (that is, the index will be created if it does not exist). ensureIndex is optimized and is inexpensive if the index already exists.
fields to use for index
an identifier for the index
(Since version 2.8) Use createIndex instead
Ensures an index on this collection (that is, the index will be created if it does not exist).
Ensures an index on this collection (that is, the index will be created if it does not exist). ensureIndex is optimized and is inexpensive if the index already exists.
fields to use for index
options for the index (name, unique, etc)
(Since version 2.8) Use createIndex instead
Creates an index on a set of fields, if one does not already exist.
Creates 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
(Since version 2.8) Use createIndex 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()
.
(Since version 2.8) This will be removed in a future release
(Since version 2.8) This will be removed in a future release
Gets the the error (if there is one) from the previous operation.
Gets the the error (if there is one) from the previous operation. The result of this command will look like
{ "err" : errorMessage , "ok" : 1.0 }
The value for errorMessage will be null if no error occurred, or a description otherwise.
Care must be taken to ensure that calls to getLastError go to the same connection as that of the previous operation. See com.mongodb.Mongo.requestStart for more information.
DBObject with error and status information
(Since version 2.8) This will be removed in a future release
(Since version 2.8) This will be removed in a future release
(Since version 2.8) This will be removed in a future release
(Since version 2.8) This will be removed in a future release
write concern aware write op block.
write concern aware write op block.
Checks getLastError after the last write. If you run multiple ops you'll only get the final error.
Your op function gets a copy of this MongoDB instance.
This is for write ops only - you cannot return data from it.
Your function must return WriteResult, which is the return type of any mongo write operation like insert/save/update/remove
(Since version 2.8) This will be removed in a future release
write concern aware write op block.
write concern aware write op block.
Checks getLastError after the last write. If you run multiple ops you'll only get the final error.
Your op function gets a copy of this MongoDB instance.
This is for write ops only - you cannot return data from it.
Your function must return WriteResult, which is the return type of any mongo write operation like insert/save/update/remove
(Since version 2.8) This will be removed in a future release
write concern aware write op block.
write concern aware write op block.
Checks getLastError after the last write. If you run multiple ops you'll only get the final error.
Your op function gets a copy of this MongoDB instance.
This is for write ops only - you cannot return data from it.
Your function must return WriteResult, which is the return type of any mongo write operation like insert/save/update/remove
If you have set a connection or DB level WriteConcern, it will be inherited.
(Since version 2.8) This will be removed in a future release
Clears all indices that have not yet been applied to this collection.
Clears all indices that have not yet been applied to this collection.
(Since version 2.8) This will be removed in a future release
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