Package | Description |
---|---|
com.mongodb |
Main package with core files.
|
com.mongodb.gridfs |
GridFS tools.
|
Modifier and Type | Class and Description |
---|---|
static class |
DBPortPool.ConnectionWaitTimeOut |
static class |
DBPortPool.NoMoreConnection |
static class |
DBPortPool.SemaphoresOut |
static class |
MongoException.CursorNotFound
Subclass of MongoException representing a cursor-not-found exception
|
static class |
MongoException.DuplicateKey
Subclass of MongoException representing a duplicate key exception
|
static class |
MongoException.Network
Subclass of MongoException representing a network-related exception
|
class |
MongoInternalException
An Mongo exception internal to the driver, not carrying any error code
|
Modifier and Type | Method and Description |
---|---|
MongoException |
CommandResult.getException()
utility method to create an exception with the command name
|
Modifier and Type | Method and Description |
---|---|
boolean |
DB.authenticate(java.lang.String username,
char[] passwd)
Authenticates to db with the given name and password
|
CommandResult |
DB.authenticateCommand(java.lang.String username,
char[] passwd)
Authenticates to db with the given name and password
|
com.mongodb.Response |
DBTCPConnector.call(DB db,
DBCollection coll,
com.mongodb.OutMessage m) |
com.mongodb.Response |
DBConnector.call(DB db,
DBCollection coll,
com.mongodb.OutMessage m)
does a read operation on the database
|
com.mongodb.Response |
DBTCPConnector.call(DB db,
DBCollection coll,
com.mongodb.OutMessage m,
ServerAddress hostNeeded) |
com.mongodb.Response |
DBConnector.call(DB db,
DBCollection coll,
com.mongodb.OutMessage m,
ServerAddress hostNeeded)
does a read operation on the database
|
com.mongodb.Response |
DBTCPConnector.call(DB db,
DBCollection coll,
com.mongodb.OutMessage m,
ServerAddress hostNeeded,
int retries) |
com.mongodb.Response |
DBConnector.call(DB db,
DBCollection coll,
com.mongodb.OutMessage m,
ServerAddress hostNeeded,
int retries)
does a read operation on the database
|
void |
DBApiLayer.cleanCursors(boolean force) |
abstract void |
DB.cleanCursors(boolean force) |
CommandResult |
DB.command(DBObject cmd)
Executes a database command.
|
CommandResult |
DB.command(DBObject cmd,
int options)
Executes a database command.
|
CommandResult |
DB.command(java.lang.String cmd)
Executes a database command.
|
CommandResult |
DB.command(java.lang.String cmd,
int options)
Executes a database command.
|
Mongo |
MongoURI.connect()
creates a Mongo instance based on the URI
|
Mongo |
Mongo.Holder.connect(MongoURI uri)
Attempts to find an existing Mongo instance matching that URI in the holder, and returns it if exists.
|
DB |
MongoURI.connectDB()
returns the DB object from a newly created Mongo instance based on this URI
|
int |
DBCursor.count()
Counts the number of objects matching the query
This does not take limit/skip into consideration
|
long |
DBCollection.count()
returns the number of documents in this collection.
|
long |
DBCollection.count(DBObject query)
returns the number of documents that match a query.
|
void |
DBCollection.createIndex(DBObject keys)
calls
DBCollection.createIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default index options |
abstract void |
DBCollection.createIndex(DBObject keys,
DBObject options)
Forces creation of an index on a set of fields, if one does not already exist.
|
CommandResult |
DB.doEval(java.lang.String code,
java.lang.Object... args)
evaluates a function on the database.
|
void |
DBCollection.drop()
Drops (deletes) this collection.
|
void |
DB.dropDatabase()
Drops this database.
|
void |
Mongo.dropDatabase(java.lang.String dbName)
Drops the database if it exists.
|
void |
DBCollection.dropIndex(DBObject keys)
Drops an index from this collection
|
void |
DBCollection.dropIndex(java.lang.String name)
Drops an index from this collection
|
void |
DBCollection.dropIndexes()
Drops all indices from this collection
|
void |
DBCollection.dropIndexes(java.lang.String name)
Drops an index from this collection
|
void |
DBCollection.ensureIndex(DBObject keys)
calls
DBCollection.ensureIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default options |
void |
DBCollection.ensureIndex(DBObject keys,
DBObject optionsIN)
Creates an index on a set of fields, if one does not already exist.
|
void |
DBCollection.ensureIndex(DBObject keys,
java.lang.String name)
calls
DBCollection.ensureIndex(com.mongodb.DBObject, java.lang.String, boolean) with unique=false |
void |
DBCollection.ensureIndex(DBObject keys,
java.lang.String name,
boolean unique)
Ensures an index on this collection (that is, the index will be created if it does not exist).
|
java.lang.Object |
DB.eval(java.lang.String code,
java.lang.Object... args)
|
DBCursor |
DBCollection.find(DBObject query,
DBObject fields,
int numToSkip,
int batchSize,
int options)
Deprecated.
|
DBObject |
DBCollection.findOne()
Returns a single object from this collection.
|
DBObject |
DBCollection.findOne(DBObject o)
Returns a single object from this collection matching the query.
|
DBObject |
DBCollection.findOne(java.lang.Object obj)
Finds an object by its id.
|
void |
DB.forceError()
For testing purposes only - this method forces an error to help test error handling
|
java.util.Set<java.lang.String> |
DB.getCollectionNames()
Returns a set containing the names of all collections in this database.
|
long |
DBCollection.getCount()
calls
DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject) with an empty query and null fields. |
long |
DBCollection.getCount(DBObject query)
calls
DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject) with null fields. |
long |
DBCollection.getCount(DBObject query,
DBObject fields)
calls
DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long) with limit=0 and skip=0 |
long |
DBCollection.getCount(DBObject query,
DBObject fields,
long limit,
long skip)
Returns the number of documents in the collection
that match the specified query
|
java.util.List<java.lang.String> |
Mongo.getDatabaseNames()
gets a list of all database names present on the server
|
CommandResult |
DB.getLastError()
Gets the the error (if there is one) from the previous operation on this connection.
|
CommandResult |
DB.getLastError(int w,
int wtimeout,
boolean fsync) |
CommandResult |
DB.getLastError(WriteConcern concern) |
CommandResult |
DB.getPreviousError()
Returns the last error that occurred since start of database or a call to
resetError()
The return object will look like |
DBObject |
DBCollection.group(DBObject args)
Deprecated.
prefer the
DBCollection.group(com.mongodb.GroupCommand) which is more standard
Applies a group operation |
DBObject |
DBCollection.group(DBObject key,
DBObject cond,
DBObject initial,
java.lang.String reduce)
|
DBObject |
DBCollection.group(DBObject key,
DBObject cond,
DBObject initial,
java.lang.String reduce,
java.lang.String finalize)
Applies a group operation
|
boolean |
DBCursor.hasNext()
Checks if there is another object available
|
WriteResult |
DBCollection.insert(DBObject... arr)
Saves document(s) to the database.
|
abstract WriteResult |
DBCollection.insert(DBObject[] arr,
WriteConcern concern)
Saves document(s) to the database.
|
WriteResult |
DBCollection.insert(DBObject o,
WriteConcern concern)
Inserts a document into the database.
|
WriteResult |
DBCollection.insert(java.util.List<DBObject> list)
Saves document(s) to the database.
|
WriteResult |
DBCollection.insert(java.util.List<DBObject> list,
WriteConcern concern)
Saves document(s) to the database.
|
int |
DBCursor.length()
pulls back all items into an array and returns the number of objects.
|
MapReduceOutput |
DBCollection.mapReduce(DBObject command)
performs a map reduce operation
|
MapReduceOutput |
DBCollection.mapReduce(MapReduceCommand command)
performs a map reduce operation
|
MapReduceOutput |
DBCollection.mapReduce(java.lang.String map,
java.lang.String reduce,
java.lang.String outputTarget,
DBObject query)
performs a map reduce operation
Runs the command in REPLACE output mode (saves to named collection)
|
MapReduceOutput |
DBCollection.mapReduce(java.lang.String map,
java.lang.String reduce,
java.lang.String outputTarget,
MapReduceCommand.OutputType outputType,
DBObject query)
performs a map reduce operation
Specify an outputType to control job execution
* INLINE - Return results inline
* REPLACE - Replace the output collection with the job output
* MERGE - Merge the job output with the existing contents of outputTarget
* REDUCE - Reduce the job output with the existing contents of
outputTarget
|
DBObject |
DBCursor.next()
Returns the object the cursor is at and moves the cursor ahead by one.
|
WriteResult |
DBCollection.remove(DBObject o)
calls
DBCollection.remove(com.mongodb.DBObject, com.mongodb.WriteConcern) with the default WriteConcern |
abstract WriteResult |
DBCollection.remove(DBObject o,
WriteConcern concern)
Removes objects from the database collection.
|
DBCollection |
DBCollection.rename(java.lang.String newName)
Calls {@link DBCollection#rename(java.lang.String, boolean) with dropTarget=false
|
DBCollection |
DBCollection.rename(java.lang.String newName,
boolean dropTarget)
renames of this collection to newName
|
void |
DB.resetError()
Resets the error memory for this database.
|
WriteResult |
DBCollection.save(DBObject jo,
WriteConcern concern)
Saves an object to this collection (does insert or update based on the object _id).
|
WriteResult |
DBTCPConnector.say(DB db,
com.mongodb.OutMessage m,
WriteConcern concern) |
WriteResult |
DBConnector.say(DB db,
com.mongodb.OutMessage m,
WriteConcern concern)
does a write operation
|
WriteResult |
DBTCPConnector.say(DB db,
com.mongodb.OutMessage m,
WriteConcern concern,
ServerAddress hostNeeded) |
WriteResult |
DBConnector.say(DB db,
com.mongodb.OutMessage m,
WriteConcern concern,
ServerAddress hostNeeded)
does a write operation
|
int |
DBCursor.size()
Counts the number of objects matching the query
this does take limit/skip into consideration
|
void |
CommandResult.throwOnError()
throws an exception containing the cmd name, in case the command failed, or the "err/code" information
|
java.util.List<DBObject> |
DBCursor.toArray()
Converts this cursor to an array.
|
java.util.List<DBObject> |
DBCursor.toArray(int max)
Converts this cursor to an array.
|
WriteResult |
DBCollection.update(DBObject q,
DBObject o)
calls
DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=false |
WriteResult |
DBCollection.update(DBObject q,
DBObject o,
boolean upsert,
boolean multi)
calls
DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean, com.mongodb.WriteConcern) with default WriteConcern. |
abstract WriteResult |
DBCollection.update(DBObject q,
DBObject o,
boolean upsert,
boolean multi,
WriteConcern concern)
Performs an update operation.
|
WriteResult |
DBCollection.updateMulti(DBObject q,
DBObject o)
calls
DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=true |
Constructor and Description |
---|
DBTCPConnector(Mongo m,
java.util.List<ServerAddress> all) |
DBTCPConnector(Mongo m,
ServerAddress... all) |
DBTCPConnector(Mongo m,
ServerAddress addr) |
MapReduceCommand(DBCollection inputCollection,
java.lang.String map,
java.lang.String reduce,
java.lang.String outputCollection,
MapReduceCommand.OutputType type,
DBObject query)
Represents the command for a map reduce operation
Runs the command in REPLACE output type to a named collection
|
Mongo()
Creates a Mongo instance based on a (single) mongodb node (localhost, default port)
|
Mongo(java.util.List<ServerAddress> replicaSetSeeds)
Creates a Mongo based on a replica set, or pair.
|
Mongo(java.util.List<ServerAddress> replicaSetSeeds,
MongoOptions options)
Creates a Mongo based on a replica set, or pair.
|
Mongo(MongoURI uri)
Creates a Mongo described by a URI.
|
Mongo(ServerAddress addr)
Creates a Mongo instance based on a (single) mongodb node
|
Mongo(ServerAddress addr,
MongoOptions options)
Creates a Mongo instance based on a (single) mongo node using a given ServerAddress
|
Mongo(ServerAddress left,
ServerAddress right)
Creates a Mongo in paired mode.
|
Mongo(ServerAddress left,
ServerAddress right,
MongoOptions options)
Creates a Mongo connection in paired mode.
|
Mongo(java.lang.String host)
Creates a Mongo instance based on a (single) mongodb node (default port)
|
Mongo(java.lang.String host,
int port)
Creates a Mongo instance based on a (single) mongodb node
|
Mongo(java.lang.String host,
MongoOptions options)
Creates a Mongo instance based on a (single) mongodb node (default port)
|
Modifier and Type | Method and Description |
---|---|
void |
GridFSFile.validate()
Verifies that the MD5 matches between the database and the local file.
|