|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mongodb.DBCollection
public abstract class DBCollection
This class provides a skeleton implementation of a database collection.
A typical invocation sequence is thus
Mongo mongo = new Mongo( new DBAddress( "localhost", 127017 ) ); DB db = mongo.getDB( "mydb" ); DBCollection collection = db.getCollection( "test" );
Field Summary | |
---|---|
protected String |
_fullName
|
protected List<DBObject> |
_hintFields
|
protected String |
_name
|
protected Class |
_objectClass
|
Constructor Summary | |
---|---|
protected |
DBCollection(DB base,
String name)
Initializes a new collection. |
Method Summary | |
---|---|
protected DBObject |
_checkObject(DBObject o,
boolean canBeNull,
boolean query)
|
void |
addOption(int option)
adds a default query option |
AggregationOutput |
aggregate(DBObject firstOp,
DBObject... additionalOps)
performs an aggregation operation |
Object |
apply(DBObject o)
calls apply(com.mongodb.DBObject, boolean) with ensureID=true |
Object |
apply(DBObject jo,
boolean ensureID)
calls doapply(com.mongodb.DBObject) , optionally adding an automatic _id field |
protected boolean |
checkReadOnly(boolean strict)
Returns if this collection's database is read-only |
long |
count()
returns the number of documents in this collection. |
long |
count(DBObject query)
returns the number of documents that match a query. |
long |
count(DBObject query,
ReadPreference readPrefs)
returns the number of documents that match a query. |
void |
createIndex(DBObject keys)
calls createIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default index options |
void |
createIndex(DBObject keys,
DBObject options)
Forces creation of an index on a set of fields, if one does not already exist. |
abstract void |
createIndex(DBObject keys,
DBObject options,
DBEncoder encoder)
Forces creation of an index on a set of fields, if one does not already exist. |
List |
distinct(String key)
find distinct values for a key |
List |
distinct(String key,
DBObject query)
find distinct values for a key |
List |
distinct(String key,
DBObject query,
ReadPreference readPrefs)
find distinct values for a key |
List |
distinct(String key,
ReadPreference readPrefs)
find distinct values for a key |
protected abstract void |
doapply(DBObject o)
Adds any necessary fields to a given object before saving it to the collection. |
void |
drop()
Drops (deletes) this collection. |
void |
dropIndex(DBObject keys)
Drops an index from this collection |
void |
dropIndex(String name)
Drops an index from this collection |
void |
dropIndexes()
Drops all indices from this collection |
void |
dropIndexes(String name)
Drops an index from this collection |
void |
ensureIndex(DBObject keys)
calls ensureIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default options |
void |
ensureIndex(DBObject keys,
DBObject optionsIN)
Creates an index on a set of fields, if one does not already exist. |
void |
ensureIndex(DBObject keys,
String name)
calls ensureIndex(com.mongodb.DBObject, java.lang.String, boolean) with unique=false |
void |
ensureIndex(DBObject keys,
String name,
boolean unique)
Ensures an index on this collection (that is, the index will be created if it does not exist). |
void |
ensureIndex(String name)
Creates an ascending index on a field with default options, if one does not already exist. |
boolean |
equals(Object o)
|
DBCursor |
find()
Queries for all objects in this collection. |
DBCursor |
find(DBObject ref)
Queries for an object in this collection. |
DBCursor |
find(DBObject ref,
DBObject keys)
Queries for an object in this collection. |
DBCursor |
find(DBObject query,
DBObject fields,
int numToSkip,
int batchSize)
Deprecated. |
DBCursor |
find(DBObject query,
DBObject fields,
int numToSkip,
int batchSize,
int options)
Deprecated. |
DBObject |
findAndModify(DBObject query,
DBObject update)
calls findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean)
with fields=null, sort=null, remove=false, returnNew=false, upsert=false |
DBObject |
findAndModify(DBObject query,
DBObject sort,
DBObject update)
calls findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean)
with fields=null, remove=false, returnNew=false, upsert=false |
DBObject |
findAndModify(DBObject query,
DBObject fields,
DBObject sort,
boolean remove,
DBObject update,
boolean returnNew,
boolean upsert)
Finds the first document in the query and updates it. |
DBObject |
findAndRemove(DBObject query)
calls findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean)
with fields=null, sort=null, remove=true, returnNew=false, upsert=false |
DBObject |
findOne()
Returns a single object from this collection. |
DBObject |
findOne(DBObject o)
Returns a single object from this collection matching the query. |
DBObject |
findOne(DBObject o,
DBObject fields)
Returns a single object from this collection matching the query. |
DBObject |
findOne(DBObject o,
DBObject fields,
DBObject orderBy)
Returns a single obejct from this collection matching the query. |
DBObject |
findOne(DBObject o,
DBObject fields,
DBObject orderBy,
ReadPreference readPref)
Returns a single object from this collection matching the query. |
DBObject |
findOne(DBObject o,
DBObject fields,
ReadPreference readPref)
Returns a single object from this collection matching the query. |
DBObject |
findOne(Object obj)
Finds an object by its id. |
DBObject |
findOne(Object obj,
DBObject fields)
Finds an object by its id. |
static String |
genIndexName(DBObject keys)
Convenience method to generate an index name from the set of fields it is over. |
DBCollection |
getCollection(String n)
Finds a collection that is prefixed with this collection's name. |
long |
getCount()
calls getCount(com.mongodb.DBObject, com.mongodb.DBObject) with an empty query and null fields. |
long |
getCount(DBObject query)
calls getCount(com.mongodb.DBObject, com.mongodb.DBObject) with null fields. |
long |
getCount(DBObject query,
DBObject fields)
calls getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long) with limit=0 and skip=0 |
long |
getCount(DBObject query,
DBObject fields,
long limit,
long skip)
calls getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long, com.mongodb.ReadPreference) with the DBCollection's ReadPreference |
long |
getCount(DBObject query,
DBObject fields,
long limit,
long skip,
ReadPreference readPrefs)
Returns the number of documents in the collection that match the specified query |
long |
getCount(DBObject query,
DBObject fields,
ReadPreference readPrefs)
calls getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long, com.mongodb.ReadPreference) with limit=0 and skip=0 |
long |
getCount(ReadPreference readPrefs)
calls getCount(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.ReadPreference) with empty query and null fields. |
DB |
getDB()
Returns the database this collection is a member of. |
DBDecoderFactory |
getDBDecoderFactory()
Get the decoder factory for this collection. |
DBEncoderFactory |
getDBEncoderFactory()
Get the encoder factory for this collection. |
String |
getFullName()
Returns the full name of this collection, with the database name as a prefix. |
List<DBObject> |
getIndexInfo()
Return a list of the indexes for this collection. |
protected Class |
getInternalClass(String path)
gets the internal class |
String |
getName()
Returns the name of this collection. |
Class |
getObjectClass()
Gets the default class for objects in the collection |
int |
getOptions()
gets the default query options |
ReadPreference |
getReadPreference()
Gets the read preference |
CommandResult |
getStats()
gets the collections statistics ("collstats" command) |
WriteConcern |
getWriteConcern()
Get the write concern for this collection. |
DBObject |
group(DBObject args)
Deprecated. prefer the group(com.mongodb.GroupCommand) which is more standard
Applies a group operation |
DBObject |
group(DBObject key,
DBObject cond,
DBObject initial,
String reduce)
calls group(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, java.lang.String, java.lang.String) with finalize=null |
DBObject |
group(DBObject key,
DBObject cond,
DBObject initial,
String reduce,
String finalize)
Applies a group operation |
DBObject |
group(DBObject key,
DBObject cond,
DBObject initial,
String reduce,
String finalize,
ReadPreference readPrefs)
Applies a group operation |
DBObject |
group(GroupCommand cmd)
Applies a group operation |
DBObject |
group(GroupCommand cmd,
ReadPreference readPrefs)
Applies a group operation |
int |
hashCode()
|
WriteResult |
insert(DBObject... arr)
Saves document(s) to the database. |
WriteResult |
insert(DBObject[] arr,
WriteConcern concern)
Saves document(s) to the database. |
abstract WriteResult |
insert(DBObject[] arr,
WriteConcern concern,
DBEncoder encoder)
Saves document(s) to the database. |
WriteResult |
insert(DBObject o,
WriteConcern concern)
Inserts a document into the database. |
WriteResult |
insert(List<DBObject> list)
Saves document(s) to the database. |
WriteResult |
insert(List<DBObject> list,
WriteConcern concern)
Saves document(s) to the database. |
WriteResult |
insert(WriteConcern concern,
DBObject... arr)
Saves document(s) to the database. |
boolean |
isCapped()
returns whether or not this is a capped collection |
MapReduceOutput |
mapReduce(DBObject command)
performs a map reduce operation |
MapReduceOutput |
mapReduce(MapReduceCommand command)
performs a map reduce operation |
MapReduceOutput |
mapReduce(String map,
String reduce,
String outputTarget,
DBObject query)
performs a map reduce operation Runs the command in REPLACE output mode (saves to named collection) |
MapReduceOutput |
mapReduce(String map,
String reduce,
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 |
MapReduceOutput |
mapReduce(String map,
String reduce,
String outputTarget,
MapReduceCommand.OutputType outputType,
DBObject query,
ReadPreference readPrefs)
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 |
WriteResult |
remove(DBObject o)
calls remove(com.mongodb.DBObject, com.mongodb.WriteConcern) with the default WriteConcern |
WriteResult |
remove(DBObject o,
WriteConcern concern)
Removes objects from the database collection. |
abstract WriteResult |
remove(DBObject o,
WriteConcern concern,
DBEncoder encoder)
Removes objects from the database collection. |
DBCollection |
rename(String newName)
Calls rename(java.lang.String, boolean) with dropTarget=false |
DBCollection |
rename(String newName,
boolean dropTarget)
renames of this collection to newName |
void |
resetIndexCache()
Clears all indices that have not yet been applied to this collection. |
void |
resetOptions()
resets the default query options |
WriteResult |
save(DBObject jo)
calls save(com.mongodb.DBObject, com.mongodb.WriteConcern) with default WriteConcern |
WriteResult |
save(DBObject jo,
WriteConcern concern)
Saves an object to this collection (does insert or update based on the object _id). |
void |
setDBDecoderFactory(DBDecoderFactory fact)
Set a customer decoder factory for this collection. |
void |
setDBEncoderFactory(DBEncoderFactory fact)
Set a customer encoder factory for this collection. |
void |
setHintFields(List<DBObject> lst)
Set hint fields for this collection (to optimize queries). |
void |
setInternalClass(String path,
Class c)
sets the internal class |
void |
setObjectClass(Class c)
Sets a default class for objects in this collection; null resets the class to nothing. |
void |
setOptions(int options)
sets the default query options |
void |
setReadPreference(ReadPreference preference)
Sets the read preference for this collection. |
void |
setWriteConcern(WriteConcern concern)
Set the write concern for this collection. |
void |
slaveOk()
Deprecated. Replaced with ReadPreference.secondaryPreferred() |
String |
toString()
|
WriteResult |
update(DBObject q,
DBObject o)
calls update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=false |
WriteResult |
update(DBObject q,
DBObject o,
boolean upsert,
boolean multi)
calls update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean, com.mongodb.WriteConcern) with default WriteConcern. |
WriteResult |
update(DBObject q,
DBObject o,
boolean upsert,
boolean multi,
WriteConcern concern)
Performs an update operation. |
abstract WriteResult |
update(DBObject q,
DBObject o,
boolean upsert,
boolean multi,
WriteConcern concern,
DBEncoder encoder)
Performs an update operation. |
WriteResult |
updateMulti(DBObject q,
DBObject o)
calls update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=true |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final String _name
protected final String _fullName
protected List<DBObject> _hintFields
protected Class _objectClass
Constructor Detail |
---|
protected DBCollection(DB base, String name)
base
- database in which to create the collectionname
- the name of the collectionMethod Detail |
---|
public WriteResult insert(DBObject[] arr, WriteConcern concern)
arr
- array of documents to saveconcern
- the write concern
MongoException
public abstract WriteResult insert(DBObject[] arr, WriteConcern concern, DBEncoder encoder)
arr
- array of documents to saveconcern
- the write concernencoder
- the DBEncoder to use
MongoException
public WriteResult insert(DBObject o, WriteConcern concern)
o
- concern
- the write concern
MongoException
public WriteResult insert(DBObject... arr)
arr
- array of documents to save
MongoException
public WriteResult insert(WriteConcern concern, DBObject... arr)
arr
- array of documents to save
MongoException
public WriteResult insert(List<DBObject> list)
list
- list of documents to save
MongoException
public WriteResult insert(List<DBObject> list, WriteConcern concern)
list
- list of documents to saveconcern
- the write concern
MongoException
public WriteResult update(DBObject q, DBObject o, boolean upsert, boolean multi, WriteConcern concern)
q
- search query for old object to updateo
- object with which to update qupsert
- if the database should create the element if it does not existmulti
- if the update should be applied to all objects matching (db version 1.1.3 and above). An object will
not be inserted if it does not exist in the collection and upsert=true and multi=true.
See http://www.mongodb.org/display/DOCS/Atomic+Operationsconcern
- the write concern
MongoException
public abstract WriteResult update(DBObject q, DBObject o, boolean upsert, boolean multi, WriteConcern concern, DBEncoder encoder)
q
- search query for old object to updateo
- object with which to update qupsert
- if the database should create the element if it does not existmulti
- if the update should be applied to all objects matching (db version 1.1.3 and above). An object will
not be inserted if it does not exist in the collection and upsert=true and multi=true.
See http://www.mongodb.org/display/DOCS/Atomic+Operationsconcern
- the write concernencoder
- the DBEncoder to use
MongoException
public WriteResult update(DBObject q, DBObject o, boolean upsert, boolean multi)
update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean, com.mongodb.WriteConcern)
with default WriteConcern.
q
- search query for old object to updateo
- object with which to update qupsert
- if the database should create the element if it does not existmulti
- if the update should be applied to all objects matching (db version 1.1.3 and above)
See http://www.mongodb.org/display/DOCS/Atomic+Operations
MongoException
public WriteResult update(DBObject q, DBObject o)
update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean)
with upsert=false and multi=false
q
- search query for old object to updateo
- object with which to update q
MongoException
public WriteResult updateMulti(DBObject q, DBObject o)
update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean)
with upsert=false and multi=true
q
- search query for old object to updateo
- object with which to update q
MongoException
protected abstract void doapply(DBObject o)
o
- object to which to add the fieldspublic WriteResult remove(DBObject o, WriteConcern concern)
o
- the object that documents to be removed must matchconcern
- WriteConcern for this operation
MongoException
public abstract WriteResult remove(DBObject o, WriteConcern concern, DBEncoder encoder)
o
- the object that documents to be removed must matchconcern
- WriteConcern for this operationencoder
- the DBEncoder to use
MongoException
public WriteResult remove(DBObject o)
remove(com.mongodb.DBObject, com.mongodb.WriteConcern)
with the default WriteConcern
o
- the object that documents to be removed must match
MongoException
@Deprecated public DBCursor find(DBObject query, DBObject fields, int numToSkip, int batchSize, int options)
find(com.mongodb.DBObject, com.mongodb.DBObject, int, int)
and applies the query options
query
- query used to searchfields
- the fields of matching objects to returnnumToSkip
- number of objects to skipbatchSize
- the batch size. This option has a complex behavior, see DBCursor.batchSize(int)
options
- - see Bytes QUERYOPTION_*
MongoException
@Deprecated public DBCursor find(DBObject query, DBObject fields, int numToSkip, int batchSize)
query
- query used to searchfields
- the fields of matching objects to returnnumToSkip
- number of objects to skipbatchSize
- the batch size. This option has a complex behavior, see DBCursor.batchSize(int)
MongoException
public DBObject findOne(Object obj)
obj
- any valid object
null
MongoException
public DBObject findOne(Object obj, DBObject fields)
obj
- any valid objectfields
- fields to return
null
MongoException
public DBObject findAndModify(DBObject query, DBObject fields, DBObject sort, boolean remove, DBObject update, boolean returnNew, boolean upsert)
query
- query to matchfields
- fields to be returnedsort
- sort to apply before picking first documentremove
- if true, document found will be removedupdate
- update to applyreturnNew
- 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)
MongoException
public DBObject findAndModify(DBObject query, DBObject sort, DBObject update)
findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean)
with fields=null, remove=false, returnNew=false, upsert=false
query
- sort
- update
-
MongoException
public DBObject findAndModify(DBObject query, DBObject update)
findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean)
with fields=null, sort=null, remove=false, returnNew=false, upsert=false
query
- update
-
MongoException
public DBObject findAndRemove(DBObject query)
findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean)
with fields=null, sort=null, remove=true, returnNew=false, upsert=false
query
-
MongoException
public void createIndex(DBObject keys)
createIndex(com.mongodb.DBObject, com.mongodb.DBObject)
with default index options
keys
- an object with a key set of the fields desired for the index
MongoException
public void createIndex(DBObject keys, DBObject options)
keys
- options
-
MongoException
public abstract void createIndex(DBObject keys, DBObject options, DBEncoder encoder)
keys
- options
- encoder
- the DBEncoder to use
MongoException
public void ensureIndex(String name)
name
- name of field to index on
MongoException
public void ensureIndex(DBObject keys)
ensureIndex(com.mongodb.DBObject, com.mongodb.DBObject)
with default options
keys
- an object with a key set of the fields desired for the index
MongoException
public void ensureIndex(DBObject keys, String name)
ensureIndex(com.mongodb.DBObject, java.lang.String, boolean)
with unique=false
keys
- fields to use for indexname
- an identifier for the index
MongoException
public void ensureIndex(DBObject keys, String name, boolean unique)
keys
- fields to use for indexname
- an identifier for the index. If null or empty, the default name will be used.unique
- if the index should be unique
MongoException
public void ensureIndex(DBObject keys, DBObject optionsIN)
keys
- an object with a key set of the fields desired for the indexoptionsIN
- options for the index (name, unique, etc)
MongoException
public void resetIndexCache()
public static String genIndexName(DBObject keys)
keys
- the names of the fields used in this index
public void setHintFields(List<DBObject> lst)
lst
- a list of DBObject
s to be used as hintspublic DBCursor find(DBObject ref)
ref
- object for which to search
public DBCursor find(DBObject ref, DBObject keys)
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 searchkeys
- fields to return
public DBCursor find()
public DBObject findOne()
null
if the collection is empty
MongoException
public DBObject findOne(DBObject o)
o
- the query object
null
if no such object exists
MongoException
public DBObject findOne(DBObject o, DBObject fields)
o
- the query objectfields
- fields to return
null
if no such object exists
MongoException
public DBObject findOne(DBObject o, DBObject fields, DBObject orderBy)
o
- the query objectfields
- fields to returnorderBy
- fields to order by
null
if no such object exists
MongoException
public DBObject findOne(DBObject o, DBObject fields, ReadPreference readPref)
o
- the query objectfields
- fields to returnreadPref
-
null
if no such object exists
MongoException
public DBObject findOne(DBObject o, DBObject fields, DBObject orderBy, ReadPreference readPref)
o
- the query objectfields
- fields to returnorderBy
- fields to order by
null
if no such object exists
MongoException
public Object apply(DBObject o)
apply(com.mongodb.DBObject, boolean)
with ensureID=true
o
- DBObject
to which to add fields
public Object apply(DBObject jo, boolean ensureID)
doapply(com.mongodb.DBObject)
, optionally adding an automatic _id field
jo
- object to add fields toensureID
- whether to add an _id
field
o
public WriteResult save(DBObject jo)
save(com.mongodb.DBObject, com.mongodb.WriteConcern)
with default WriteConcern
jo
- the DBObject
to save
will add _id
field to jo if needed
MongoException
public WriteResult save(DBObject jo, WriteConcern concern)
jo
- the DBObject
to saveconcern
- the write concern
MongoException
public void dropIndexes()
MongoException
public void dropIndexes(String name)
name
- the index name
MongoException
public void drop()
MongoException
public long count()
MongoException
public long count(DBObject query)
query
- query to match
MongoException
public long count(DBObject query, ReadPreference readPrefs)
query
- query to matchreadPrefs
- ReadPreferences for this query
MongoException
public long getCount()
getCount(com.mongodb.DBObject, com.mongodb.DBObject)
with an empty query and null fields.
MongoException
public long getCount(ReadPreference readPrefs)
getCount(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.ReadPreference)
with empty query and null fields.
readPrefs
- ReadPreferences for this command
MongoException
public long getCount(DBObject query)
getCount(com.mongodb.DBObject, com.mongodb.DBObject)
with null fields.
query
- query to match
MongoException
public long getCount(DBObject query, DBObject fields)
getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long)
with limit=0 and skip=0
query
- query to matchfields
- fields to return
MongoException
public long getCount(DBObject query, DBObject fields, ReadPreference readPrefs)
getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long, com.mongodb.ReadPreference)
with limit=0 and skip=0
query
- query to matchfields
- fields to returnreadPrefs
- ReadPreferences for this command
MongoException
public long getCount(DBObject query, DBObject fields, long limit, long skip)
getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long, com.mongodb.ReadPreference)
with the DBCollection's ReadPreference
query
- query to matchfields
- fields to returnlimit
- limit the count to this valueskip
- skip number of entries to skip
MongoException
public long getCount(DBObject query, DBObject fields, long limit, long skip, ReadPreference readPrefs)
query
- query to select documents to countfields
- fields to returnlimit
- limit the count to this valueskip
- number of entries to skipreadPrefs
- ReadPreferences for this command
MongoException
public DBCollection rename(String newName)
rename(java.lang.String, boolean)
with dropTarget=false
newName
- new collection name (not a full namespace)
MongoException
public DBCollection rename(String newName, boolean dropTarget)
newName
- new collection name (not a full namespace)dropTarget
- if a collection with the new name exists, whether or not to drop it
MongoException
public DBObject group(DBObject key, DBObject cond, DBObject initial, String reduce)
group(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, java.lang.String, java.lang.String)
with finalize=null
key
- - { a : true }cond
- - optional condition on queryreduce
- javascript reduce functioninitial
- initial value for first match on a key
MongoException
public DBObject group(DBObject key, DBObject cond, DBObject initial, String reduce, String finalize)
key
- - { a : true }cond
- - optional condition on queryreduce
- javascript reduce functioninitial
- initial value for first match on a keyfinalize
- An optional function that can operate on the result(s) of the reduce function.
MongoException
public DBObject group(DBObject key, DBObject cond, DBObject initial, String reduce, String finalize, ReadPreference readPrefs)
key
- - { a : true }cond
- - optional condition on queryreduce
- javascript reduce functioninitial
- initial value for first match on a keyfinalize
- An optional function that can operate on the result(s) of the reduce function.readPrefs
- ReadPreferences for this command
MongoException
public DBObject group(GroupCommand cmd)
cmd
- the group command
MongoException
public DBObject group(GroupCommand cmd, ReadPreference readPrefs)
cmd
- the group commandreadPrefs
- ReadPreferences for this command
MongoException
@Deprecated public DBObject group(DBObject args)
group(com.mongodb.GroupCommand)
which is more standard
Applies a group operation
args
- object representing the arguments to the group function
MongoException
public List distinct(String key)
key
-
MongoException
public List distinct(String key, ReadPreference readPrefs)
key
- readPrefs
-
MongoException
public List distinct(String key, DBObject query)
key
- query
- query to match
MongoException
public List distinct(String key, DBObject query, ReadPreference readPrefs)
key
- query
- query to matchreadPrefs
-
MongoException
public MapReduceOutput mapReduce(String map, String reduce, String outputTarget, DBObject query)
map
- map function in javascript codeoutputTarget
- optional - leave null if want to use temp collectionreduce
- reduce function in javascript codequery
- to match
MongoException
public MapReduceOutput mapReduce(String map, String reduce, String outputTarget, MapReduceCommand.OutputType outputType, DBObject query)
map
- map function in javascript codeoutputTarget
- optional - leave null if want to use temp collectionoutputType
- set the type of job outputreduce
- reduce function in javascript codequery
- to match
MongoException
public MapReduceOutput mapReduce(String map, String reduce, String outputTarget, MapReduceCommand.OutputType outputType, DBObject query, ReadPreference readPrefs)
map
- map function in javascript codeoutputTarget
- optional - leave null if want to use temp collectionoutputType
- set the type of job outputreduce
- reduce function in javascript codequery
- to matchreadPrefs
- ReadPreferences for this operation
MongoException
public MapReduceOutput mapReduce(MapReduceCommand command)
command
- object representing the parameters
MongoException
public MapReduceOutput mapReduce(DBObject command)
command
- object representing the parameters
MongoException
public AggregationOutput aggregate(DBObject firstOp, DBObject... additionalOps)
firstOp
- requisite first operation to be performed in the aggregation pipelineadditionalOps
- additional operations to be performed in the aggregation pipeline
public List<DBObject> getIndexInfo()
MongoException
public void dropIndex(DBObject keys)
keys
- keys of the index
MongoException
public void dropIndex(String name)
name
- name of index to drop
MongoException
public CommandResult getStats()
MongoException
public boolean isCapped()
MongoException
protected DBObject _checkObject(DBObject o, boolean canBeNull, boolean query)
public DBCollection getCollection(String n)
Which is equivalent toDBCollection users = mongo.getCollection( "wiki" ).getCollection( "users" );
DBCollection users = mongo.getCollection( "wiki.users" );
n
- the name of the collection to find
public String getName()
public String getFullName()
public DB getDB()
protected boolean checkReadOnly(boolean strict)
strict
- if an exception should be thrown if the database is read-only
RuntimeException
- if the database is read-only and strict
is setpublic int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
public String toString()
toString
in class Object
public void setObjectClass(Class c)
c
- the class
IllegalArgumentException
- if c
is not a DBObjectpublic Class getObjectClass()
public void setInternalClass(String path, Class c)
path
- c
- protected Class getInternalClass(String path)
path
-
public void setWriteConcern(WriteConcern concern)
WriteConcern
for more information.
concern
- write concern to usepublic WriteConcern getWriteConcern()
public void setReadPreference(ReadPreference preference)
ReadPreference
for more information.
preference
- Read Preference to usepublic ReadPreference getReadPreference()
@Deprecated public void slaveOk()
ReadPreference.secondaryPreferred()
ReadPreference.secondaryPreferred()
public void addOption(int option)
option
- public void setOptions(int options)
options
- public void resetOptions()
public int getOptions()
public void setDBDecoderFactory(DBDecoderFactory fact)
fact
- the factory to set.public DBDecoderFactory getDBDecoderFactory()
public void setDBEncoderFactory(DBEncoderFactory fact)
fact
- the factory to set.public DBEncoderFactory getDBEncoderFactory()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |