|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mongodb.DB
public abstract class DB
a logical database on a server
Field Summary | |
---|---|
protected boolean |
_readOnly
|
Constructor Summary | |
---|---|
DB(Mongo mongo,
String name)
|
Method Summary | |
---|---|
void |
addOption(int option)
|
void |
addUser(String username,
char[] passwd)
|
boolean |
authenticate(String username,
char[] passwd)
Authenticates connection/db with given name and password |
boolean |
collectionExists(String collectionName)
Checks to see if a collection by name %lt;name> exists. |
CommandResult |
command(DBObject cmd)
Execute a database command directly. |
CommandResult |
command(DBObject cmd,
int options)
Execute a database command directly. |
CommandResult |
command(String cmd)
|
DBCollection |
createCollection(String name,
DBObject o)
Creates a collection with a given name and options. |
CommandResult |
doEval(String code,
Object... args)
|
protected abstract DBCollection |
doGetCollection(String name)
Returns the collection represented by the string <dbName>.<collectionName>. |
void |
dropDatabase()
Drops this database. |
Object |
eval(String code,
Object... args)
|
void |
forceError()
For testing purposes only - this method forces an error to help test error handling |
DBCollection |
getCollection(String name)
Gets a collection with a given name. |
DBCollection |
getCollectionFromString(String s)
Returns a collection matching a given string. |
Set<String> |
getCollectionNames()
Returns a set of the names of collections in this database. |
CommandResult |
getLastError()
Gets the the error (if there is one) from the previous operation. |
CommandResult |
getLastError(int w,
int wtimeout,
boolean fsync)
|
CommandResult |
getLastError(WriteConcern concern)
|
Mongo |
getMongo()
|
String |
getName()
Returns the name of this database. |
int |
getOptions()
|
CommandResult |
getPreviousError()
Returns the last error that occurred since start of database or a call to resetError()
The return object will look like |
DB |
getSisterDB(String name)
|
CommandResult |
getStats()
|
WriteConcern |
getWriteConcern()
Get the write concern for this database. |
boolean |
isAuthenticated()
Returns true iff this DB is authenticated |
abstract void |
requestDone()
|
abstract void |
requestEnsureConnection()
|
abstract void |
requestStart()
|
void |
resetError()
Resets the error memory for this database. |
void |
resetIndexCache()
Clears any indices that have not yet been applied to the collections in this database. |
void |
resetOptions()
|
void |
setOptions(int options)
|
void |
setReadOnly(Boolean b)
Makes this database read-only |
void |
setWriteConcern(WriteConcern concern)
Set the write concern for this database. |
void |
slaveOk()
makes this query ok to run on a slave node |
String |
toString()
Returns the name of this database. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean _readOnly
Constructor Detail |
---|
public DB(Mongo mongo, String name)
Method Detail |
---|
public abstract void requestStart()
public abstract void requestDone()
public abstract void requestEnsureConnection()
protected abstract DBCollection doGetCollection(String name)
name
- the name of the collection
public final DBCollection getCollection(String name)
name
- the name of the collection to return
public final DBCollection createCollection(String name, DBObject o)
name
- the name of the collection to returno
- options
public DBCollection getCollectionFromString(String s)
s
- the name of the collection
public CommandResult command(DBObject cmd) throws MongoException
MongoException
public CommandResult command(DBObject cmd, int options) throws MongoException
MongoException
public CommandResult command(String cmd) throws MongoException
MongoException
public CommandResult doEval(String code, Object... args) throws MongoException
MongoException
public Object eval(String code, Object... args) throws MongoException
MongoException
public CommandResult getStats()
public String getName()
public void setReadOnly(Boolean b)
b
- if the database should be read-onlypublic Set<String> getCollectionNames() throws MongoException
MongoException
public boolean collectionExists(String collectionName)
collectionName
- The collection to test for existence
public String toString()
toString
in class Object
public void resetIndexCache()
public CommandResult getLastError() throws MongoException
{ "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.
MongoException
public CommandResult getLastError(WriteConcern concern) throws MongoException
MongoException
public CommandResult getLastError(int w, int wtimeout, boolean fsync) throws MongoException
MongoException
public void setWriteConcern(WriteConcern concern)
WriteConcern
for more information.
concern
- write concern to usepublic WriteConcern getWriteConcern()
public void dropDatabase() throws MongoException
MongoException
public boolean isAuthenticated()
public boolean authenticate(String username, char[] passwd) throws MongoException
username
- name of user for this databasepasswd
- password of user for this database
MongoException
public void addUser(String username, char[] passwd)
public CommandResult getPreviousError() throws MongoException
resetError()
The return object will look like
{ err : errorMessage, nPrev : countOpsBack, ok : 1 }The value for errormMessage will be null of no error has ocurred, or the message. The value of countOpsBack will be the number of operations since the error occurred. Care must be taken to ensure that calls to getPreviousError go to the same connection as that of the previous operation. See com.mongodb.Mongo.requestStart for more information.
MongoException
public void resetError() throws MongoException
MongoException
public void forceError() throws MongoException
MongoException
public Mongo getMongo()
public DB getSisterDB(String name)
public void slaveOk()
public void addOption(int option)
public void setOptions(int options)
public void resetOptions()
public int getOptions()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |