public interface MongoCollection
Modifier and Type | Interface and Description |
---|---|
static class |
MongoCollection.ValidateMode
ValidateMode provides an enumeration of the validation modes.
|
Modifier and Type | Field and Description |
---|---|
static Document |
ALL
An (empty) query document to find all documents.
|
Modifier and Type | Method and Description |
---|---|
List<Document> |
aggregate(Aggregate.Builder command)
Invokes a aggregate command on the server.
|
List<Document> |
aggregate(Aggregate command)
Invokes a aggregate command on the server.
|
Future<List<Document>> |
aggregateAsync(Aggregate.Builder command)
Invokes a aggregate command on the server.
|
Future<List<Document>> |
aggregateAsync(Aggregate command)
Invokes a aggregate command on the server.
|
void |
aggregateAsync(Callback<List<Document>> results,
Aggregate.Builder command)
Invokes a aggregate command on the server.
|
void |
aggregateAsync(Callback<List<Document>> results,
Aggregate command)
Invokes a aggregate command on the server.
|
long |
count()
Counts the set of documents in the collection.
|
long |
count(DocumentAssignable query)
Counts the set of documents matching the query document in the
collection.
|
long |
count(DocumentAssignable query,
ReadPreference readPreference)
Counts the set of documents matching the query document in the
collection.
|
long |
count(ReadPreference readPreference)
Counts the set of documents in the collection.
|
Future<Long> |
countAsync()
Counts the set of documents in the collection.
|
void |
countAsync(Callback<Long> results)
Counts the set of documents in the collection.
|
void |
countAsync(Callback<Long> results,
DocumentAssignable query)
Counts the set of documents matching the query document in the
collection.
|
void |
countAsync(Callback<Long> results,
DocumentAssignable query,
ReadPreference readPreference)
Counts the set of documents matching the query document in the
collection.
|
void |
countAsync(Callback<Long> results,
ReadPreference readPreference)
Counts the set of documents in the collection.
|
Future<Long> |
countAsync(DocumentAssignable query)
Counts the set of documents matching the query document in the
collection.
|
Future<Long> |
countAsync(DocumentAssignable query,
ReadPreference readPreference)
Counts the set of documents matching the query document in the
collection.
|
Future<Long> |
countAsync(ReadPreference readPreference)
Counts the set of documents in the collection.
|
void |
createIndex(boolean unique,
Element... keys)
Creates an index with a generated name, across the keys specified and if
unique is true ensuring entries are unique.
|
void |
createIndex(DocumentAssignable options,
Element... keys)
Creates an index with a generated name, across the keys specified
allowing duplicate entries.
|
void |
createIndex(Element... keys)
Creates an index with a generated name, across the keys specified
allowing duplicate entries.
|
void |
createIndex(String name,
boolean unique,
Element... keys)
Creates an index with the specified name, across the keys specified and
if unique is true ensuring entries are unique.
|
void |
createIndex(String name,
DocumentAssignable options,
Element... keys)
Creates an index with a generated name, across the keys specified
allowing duplicate entries.
|
long |
delete(DocumentAssignable query)
Deletes a set of documents matching a query from the collection.
|
long |
delete(DocumentAssignable query,
boolean singleDelete)
Deletes a set of documents matching a query from the collection.
|
long |
delete(DocumentAssignable query,
boolean singleDelete,
Durability durability)
Deletes a set of documents matching a query from the collection.
|
long |
delete(DocumentAssignable query,
Durability durability)
Deletes a set of documents matching a query from the collection.
|
void |
deleteAsync(Callback<Long> results,
DocumentAssignable query)
Deletes a set of documents matching a query from the collection.
|
void |
deleteAsync(Callback<Long> results,
DocumentAssignable query,
boolean singleDelete)
Deletes a set of documents matching a query from the collection.
|
void |
deleteAsync(Callback<Long> results,
DocumentAssignable query,
boolean singleDelete,
Durability durability)
Deletes a set of documents matching a query from the collection.
|
void |
deleteAsync(Callback<Long> results,
DocumentAssignable query,
Durability durability)
Deletes a set of documents matching a query from the collection.
|
Future<Long> |
deleteAsync(DocumentAssignable query)
Deletes a set of documents matching a query from the collection.
|
Future<Long> |
deleteAsync(DocumentAssignable query,
boolean singleDelete)
Deletes a set of documents matching a query from the collection.
|
Future<Long> |
deleteAsync(DocumentAssignable query,
boolean singleDelete,
Durability durability)
Deletes a set of documents matching a query from the collection.
|
Future<Long> |
deleteAsync(DocumentAssignable query,
Durability durability)
Deletes a set of documents matching a query from the collection.
|
ArrayElement |
distinct(Distinct.Builder command)
Invokes a distinct command on the server.
|
ArrayElement |
distinct(Distinct command)
Invokes a distinct command on the server.
|
void |
distinctAsync(Callback<ArrayElement> results,
Distinct.Builder command)
Invokes a distinct command on the server.
|
void |
distinctAsync(Callback<ArrayElement> results,
Distinct command)
Invokes a distinct command on the server.
|
Future<ArrayElement> |
distinctAsync(Distinct.Builder command)
Invokes a distinct command on the server.
|
Future<ArrayElement> |
distinctAsync(Distinct command)
Invokes a distinct command on the server.
|
boolean |
drop()
Drops the collection from the database.
|
boolean |
dropIndex(IntegerElement... keys)
Deletes the indexes matching the keys specified.
|
boolean |
dropIndex(String name)
Deletes the indexes with the provided name.
|
Document |
explain(DocumentAssignable query)
Explains the way that the document will be performed.
|
Document |
explain(Find.Builder query)
Explains the way that the document will be performed.
|
Document |
explain(Find query)
Explains the way that the document will be performed.
|
void |
explainAsync(Callback<Document> results,
Find.Builder query)
Explains the way that the document will be performed.
|
void |
explainAsync(Callback<Document> results,
Find query)
Explains the way that the document will be performed.
|
Future<Document> |
explainAsync(Find.Builder query)
Explains the way that the document will be performed.
|
Future<Document> |
explainAsync(Find query)
Explains the way that the document will be performed.
|
MongoIterator<Document> |
find(DocumentAssignable query)
Finds the set of documents matching the query document in the collection.
|
MongoIterator<Document> |
find(Find.Builder query)
Finds the set of documents matching the query in the collection.
|
MongoIterator<Document> |
find(Find query)
Finds the set of documents matching the query in the collection.
|
Document |
findAndModify(FindAndModify.Builder command)
Invokes a findAndModify command on the server.
|
Document |
findAndModify(FindAndModify command)
Invokes a findAndModify command on the server.
|
void |
findAndModifyAsync(Callback<Document> results,
FindAndModify.Builder command)
Invokes a findAndModify command on the server.
|
void |
findAndModifyAsync(Callback<Document> results,
FindAndModify command)
Invokes a findAndModify command on the server.
|
Future<Document> |
findAndModifyAsync(FindAndModify.Builder command)
Invokes a findAndModify command on the server.
|
Future<Document> |
findAndModifyAsync(FindAndModify command)
Invokes a findAndModify command on the server.
|
void |
findAsync(Callback<MongoIterator<Document>> results,
DocumentAssignable query)
Finds the set of documents matching the query document in the collection.
|
void |
findAsync(Callback<MongoIterator<Document>> results,
Find.Builder query)
Finds the set of documents matching the query in the collection.
|
void |
findAsync(Callback<MongoIterator<Document>> results,
Find query)
Finds the set of documents matching the query in the collection.
|
Future<MongoIterator<Document>> |
findAsync(DocumentAssignable query)
Finds the set of documents matching the query document in the collection.
|
Future<MongoIterator<Document>> |
findAsync(Find.Builder query)
Finds the set of documents matching the query in the collection.
|
Future<MongoIterator<Document>> |
findAsync(Find query)
Finds the set of documents matching the query in the collection.
|
Document |
findOne(DocumentAssignable query)
Finds a single matching document in the collection.
|
Document |
findOne(Find.Builder query)
Finds a single matching document in the collection.
|
Document |
findOne(Find query)
Finds a single matching document in the collection.
|
void |
findOneAsync(Callback<Document> results,
DocumentAssignable query)
Finds a single matching document in the collection.
|
void |
findOneAsync(Callback<Document> results,
Find.Builder query)
Finds a single matching document in the collection.
|
void |
findOneAsync(Callback<Document> results,
Find query)
Finds a single matching document in the collection.
|
Future<Document> |
findOneAsync(DocumentAssignable query)
Finds a single matching document in the collection.
|
Future<Document> |
findOneAsync(Find.Builder query)
Finds a single matching document in the collection.
|
Future<Document> |
findOneAsync(Find query)
Finds a single matching document in the collection.
|
String |
getDatabaseName()
Returns the name of the database.
|
Durability |
getDurability()
Returns the durability for write operations sent to the server from this
MongoCollection instance. |
String |
getName()
Returns the name of the collection.
|
ReadPreference |
getReadPreference()
Returns the read preference for queries from this
MongoCollection
instance. |
ArrayElement |
groupBy(GroupBy.Builder command)
Invokes a group command on the server.
|
ArrayElement |
groupBy(GroupBy command)
Invokes a group command on the server.
|
void |
groupByAsync(Callback<ArrayElement> results,
GroupBy.Builder command)
Invokes a group command on the server.
|
void |
groupByAsync(Callback<ArrayElement> results,
GroupBy command)
Invokes a group command on the server.
|
Future<ArrayElement> |
groupByAsync(GroupBy.Builder command)
Invokes a group command on the server.
|
Future<ArrayElement> |
groupByAsync(GroupBy command)
Invokes a group command on the server.
|
int |
insert(boolean continueOnError,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
int |
insert(boolean continueOnError,
Durability durability,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
int |
insert(DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
int |
insert(Durability durability,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
Future<Integer> |
insertAsync(boolean continueOnError,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
Future<Integer> |
insertAsync(boolean continueOnError,
Durability durability,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
void |
insertAsync(Callback<Integer> results,
boolean continueOnError,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
void |
insertAsync(Callback<Integer> results,
boolean continueOnError,
Durability durability,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
void |
insertAsync(Callback<Integer> results,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
void |
insertAsync(Callback<Integer> results,
Durability durability,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
Future<Integer> |
insertAsync(DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
Future<Integer> |
insertAsync(Durability durability,
DocumentAssignable... documents)
Inserts a set of documents into the collection.
|
boolean |
isCapped()
Returns true if the collection
statistics indicate that
the collection is a capped collection. |
List<Document> |
mapReduce(MapReduce.Builder command)
Invokes a mapReduce command on the server.
|
List<Document> |
mapReduce(MapReduce command)
Invokes a mapReduce command on the server.
|
void |
mapReduceAsync(Callback<List<Document>> results,
MapReduce.Builder command)
Invokes a mapReduce command on the server.
|
void |
mapReduceAsync(Callback<List<Document>> results,
MapReduce command)
Invokes a mapReduce command on the server.
|
Future<List<Document>> |
mapReduceAsync(MapReduce.Builder command)
Invokes a mapReduce command on the server.
|
Future<List<Document>> |
mapReduceAsync(MapReduce command)
Invokes a mapReduce command on the server.
|
int |
save(DocumentAssignable document)
Saves the
document to the collection. |
int |
save(DocumentAssignable document,
Durability durability)
Saves the
document to the collection. |
void |
saveAsync(Callback<Integer> results,
DocumentAssignable document)
Saves the
document to the collection. |
void |
saveAsync(Callback<Integer> results,
DocumentAssignable document,
Durability durability)
Saves the
document to the collection. |
Future<Integer> |
saveAsync(DocumentAssignable document)
Saves the
document to the collection. |
Future<Integer> |
saveAsync(DocumentAssignable document,
Durability durability)
Saves the
document to the collection. |
void |
setDurability(Durability durability)
Sets the durability for write operations from this
MongoCollection instance. |
void |
setReadPreference(ReadPreference readPreference)
Sets the value of the read preference for a queries from this
MongoCollection instance. |
Document |
stats()
Returns the statistics for the collection.
|
MongoCursorControl |
streamingFind(Callback<Document> results,
DocumentAssignable query)
Deprecated.
Use the
streamingFind(StreamCallback, DocumentAssignable)
method instead. This method will be removed after the 1.3.0
release. |
MongoCursorControl |
streamingFind(Callback<Document> results,
Find query)
Deprecated.
Use the
streamingFind(StreamCallback, Find) method
instead. This method will be removed after the 1.3.0 release. |
MongoCursorControl |
streamingFind(StreamCallback<Document> results,
DocumentAssignable query)
Finds the set of documents matching the query document in the collection
and streams them to the provided callback one at a time.
|
MongoCursorControl |
streamingFind(StreamCallback<Document> results,
Find.Builder query)
Finds the set of documents matching the query in the collection and
streams them to the provided callback one at a time.
|
MongoCursorControl |
streamingFind(StreamCallback<Document> results,
Find query)
Finds the set of documents matching the query in the collection and
streams them to the provided callback one at a time.
|
List<TextResult> |
textSearch(Text.Builder command)
Invokes a
text command on the server. |
List<TextResult> |
textSearch(Text command)
Invokes a
text command on the server. |
void |
textSearchAsync(Callback<List<TextResult>> results,
Text.Builder command)
Invokes a
text command on the server. |
void |
textSearchAsync(Callback<List<TextResult>> results,
Text command)
Invokes a
text command on the server. |
Future<List<TextResult>> |
textSearchAsync(Text.Builder command)
Invokes a
text command on the server. |
Future<List<TextResult>> |
textSearchAsync(Text command)
Invokes a
text command on the server. |
long |
update(DocumentAssignable query,
DocumentAssignable update)
Applies updates to a set of documents within the collection.
|
long |
update(DocumentAssignable query,
DocumentAssignable update,
boolean multiUpdate,
boolean upsert)
Applies updates to a set of documents within the collection.
|
long |
update(DocumentAssignable query,
DocumentAssignable update,
boolean multiUpdate,
boolean upsert,
Durability durability)
Applies updates to a set of documents within the collection.
|
long |
update(DocumentAssignable query,
DocumentAssignable update,
Durability durability)
Applies updates to a set of documents within the collection.
|
void |
updateAsync(Callback<Long> results,
DocumentAssignable query,
DocumentAssignable update)
Applies updates to a set of documents within the collection.
|
void |
updateAsync(Callback<Long> results,
DocumentAssignable query,
DocumentAssignable update,
boolean multiUpdate,
boolean upsert)
Applies updates to a set of documents within the collection.
|
void |
updateAsync(Callback<Long> results,
DocumentAssignable query,
DocumentAssignable update,
boolean multiUpdate,
boolean upsert,
Durability durability)
Applies updates to a set of documents within the collection.
|
void |
updateAsync(Callback<Long> results,
DocumentAssignable query,
DocumentAssignable update,
Durability durability)
Applies updates to a set of documents within the collection.
|
Future<Long> |
updateAsync(DocumentAssignable query,
DocumentAssignable update)
Applies updates to a set of documents within the collection.
|
Future<Long> |
updateAsync(DocumentAssignable query,
DocumentAssignable update,
boolean multiUpdate,
boolean upsert)
Applies updates to a set of documents within the collection.
|
Future<Long> |
updateAsync(DocumentAssignable query,
DocumentAssignable update,
boolean multiUpdate,
boolean upsert,
Durability durability)
Applies updates to a set of documents within the collection.
|
Future<Long> |
updateAsync(DocumentAssignable query,
DocumentAssignable update,
Durability durability)
Applies updates to a set of documents within the collection.
|
Document |
updateOptions(DocumentAssignable options)
Updates the collection's options or flags using the
collMod
command. |
Document |
validate(MongoCollection.ValidateMode mode)
Validates the collections contents.
|
static final Document ALL
List<Document> aggregate(Aggregate command) throws MongoDbException
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.List<Document> aggregate(Aggregate.Builder command) throws MongoDbException
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.Future<List<Document>> aggregateAsync(Aggregate command) throws MongoDbException
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.Future<List<Document>> aggregateAsync(Aggregate.Builder command) throws MongoDbException
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.void aggregateAsync(Callback<List<Document>> results, Aggregate command) throws MongoDbException
results
- Callback for the aggregation results returned.command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.void aggregateAsync(Callback<List<Document>> results, Aggregate.Builder command) throws MongoDbException
results
- Callback for the aggregation results returned.command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.long count() throws MongoDbException
This is equivalent to calling countAsync().get()
MongoDbException
- On an error finding the documents.long count(DocumentAssignable query) throws MongoDbException
This is equivalent to calling countAsync(...).get()
query
- The query document.MongoDbException
- On an error finding the documents.long count(DocumentAssignable query, ReadPreference readPreference) throws MongoDbException
query
- The query document.readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.long count(ReadPreference readPreference) throws MongoDbException
This is equivalent to calling countAsync().get()
readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.Future<Long> countAsync() throws MongoDbException
This is equivalent to calling countAsync().get()
MongoDbException
- On an error finding the documents.void countAsync(Callback<Long> results) throws MongoDbException
This is equivalent to calling
countAsync(results,
BuilderFactory.start())
results
- The callback to notify of the results.MongoDbException
- On an error finding the documents.void countAsync(Callback<Long> results, DocumentAssignable query) throws MongoDbException
results
- The callback to notify of the results.query
- The query document.MongoDbException
- On an error finding the documents.void countAsync(Callback<Long> results, DocumentAssignable query, ReadPreference readPreference) throws MongoDbException
results
- The callback to notify of the results.query
- The query document.readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.void countAsync(Callback<Long> results, ReadPreference readPreference) throws MongoDbException
This is equivalent to calling
countAsync(results,
BuilderFactory.start(), readPreference)
results
- The callback to notify of the results.readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.Future<Long> countAsync(DocumentAssignable query) throws MongoDbException
query
- The query document.MongoDbException
- On an error finding the documents.Future<Long> countAsync(DocumentAssignable query, ReadPreference readPreference) throws MongoDbException
query
- The query document.readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.Future<Long> countAsync(ReadPreference readPreference) throws MongoDbException
This is equivalent to calling countAsync().get()
readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.void createIndex(boolean unique, Element... keys) throws MongoDbException
This method is intended to be used with the
Index
class's static methods:
import static
com.allanbank.mongodb.builder.Index.asc
; import staticcom.allanbank.mongodb.builder.Index.desc
; MongoCollection collection = ...; collection.createIndex( true, asc("f"), desc("g") ); ...
unique
- If true then the index created will enforce entries are
unique.keys
- The keys to use for the index.MongoDbException
- On a failure building the index.void createIndex(DocumentAssignable options, Element... keys) throws MongoDbException
This method is intended to be used with the
Index
class's static methods:
import static
com.allanbank.mongodb.bson.builder.BuilderFactory.start
; import staticcom.allanbank.mongodb.builder.Index.asc
; import staticcom.allanbank.mongodb.builder.Index.desc
; MongoCollection collection = ...; collection.createIndex(start().add("sparse", true), asc("f") ); ...
options
- The options for the index.keys
- The keys to use for the index.MongoDbException
- On a failure building the index.void createIndex(Element... keys) throws MongoDbException
This method is intended to be used with the
Index
class's static methods:
import static
com.allanbank.mongodb.builder.Index.asc
; import staticcom.allanbank.mongodb.builder.Index.desc
; MongoCollection collection = ...; collection.createIndex( asc("f"), desc("g") ); ...
keys
- The keys to use for the index.MongoDbException
- On a failure building the index.void createIndex(String name, boolean unique, Element... keys) throws MongoDbException
This method is intended to be used with the
Index
class's static methods:
import static
com.allanbank.mongodb.builder.Index.asc
; import staticcom.allanbank.mongodb.builder.Index.desc
; MongoCollection collection = ...; collection.createIndex( "f_and_g", false, asc("f"), desc("g") ); ...
name
- The name of the index. If null
then a name is
generated based on the keys.keys
- The keys to use for the index.unique
- If true then the index created will enforce entries are
unique.MongoDbException
- On a failure building the index.void createIndex(String name, DocumentAssignable options, Element... keys) throws MongoDbException
This method is intended to be used with the
Index
class's static methods:
import static
com.allanbank.mongodb.bson.builder.BuilderFactory.start
; import staticcom.allanbank.mongodb.builder.Index.asc
; import staticcom.allanbank.mongodb.builder.Index.desc
; MongoCollection collection = ...; collection.createIndex("sparse_f", start().add("sparse", true), asc("f") ); ...
name
- The name of the index. If null
then a name is
generated based on the keys.options
- The options for the index.keys
- The keys to use for the index.MongoDbException
- On a failure building the index.long delete(DocumentAssignable query) throws MongoDbException
query
- Query to locate the documents to be deleted.MongoDbException
- On an error deleting the documents.long delete(DocumentAssignable query, boolean singleDelete) throws MongoDbException
query
- Query to locate the documents to be deleted.singleDelete
- If true then only a single document will be deleted. If
running in a sharded environment then this field must be false
or the query must contain the shard key.MongoDbException
- On an error deleting the documents.long delete(DocumentAssignable query, boolean singleDelete, Durability durability) throws MongoDbException
query
- Query to locate the documents to be deleted.singleDelete
- If true then only a single document will be deleted. If
running in a sharded environment then this field must be false
or the query must contain the shard key.durability
- The durability for the delete.MongoDbException
- On an error deleting the documents.long delete(DocumentAssignable query, Durability durability) throws MongoDbException
query
- Query to locate the documents to be deleted.durability
- The durability for the delete.MongoDbException
- On an error deleting the documents.void deleteAsync(Callback<Long> results, DocumentAssignable query) throws MongoDbException
results
- Callback that will be notified of the results of the query. If
the durability of the operation is NONE then this will be -1.query
- Query to locate the documents to be deleted.MongoDbException
- On an error deleting the documents.void deleteAsync(Callback<Long> results, DocumentAssignable query, boolean singleDelete) throws MongoDbException
results
- Callback that will be notified of the results of the query. If
the durability of the operation is NONE then this will be -1.query
- Query to locate the documents to be deleted.singleDelete
- If true then only a single document will be deleted. If
running in a sharded environment then this field must be false
or the query must contain the shard key.MongoDbException
- On an error deleting the documents.void deleteAsync(Callback<Long> results, DocumentAssignable query, boolean singleDelete, Durability durability) throws MongoDbException
results
- Callback that will be notified of the results of the query. If
the durability of the operation is NONE then this will be -1.query
- Query to locate the documents to be deleted.singleDelete
- If true then only a single document will be deleted. If
running in a sharded environment then this field must be false
or the query must contain the shard key.durability
- The durability for the delete.MongoDbException
- On an error deleting the documents.void deleteAsync(Callback<Long> results, DocumentAssignable query, Durability durability) throws MongoDbException
results
- Callback that will be notified of the results of the query. If
the durability of the operation is NONE then this will be -1.query
- Query to locate the documents to be deleted.durability
- The durability for the delete.MongoDbException
- On an error deleting the documents.Future<Long> deleteAsync(DocumentAssignable query) throws MongoDbException
query
- Query to locate the documents to be deleted.MongoDbException
- On an error deleting the documents.Future<Long> deleteAsync(DocumentAssignable query, boolean singleDelete) throws MongoDbException
query
- Query to locate the documents to be deleted.singleDelete
- If true then only a single document will be deleted. If
running in a sharded environment then this field must be false
or the query must contain the shard key.MongoDbException
- On an error deleting the documents.Future<Long> deleteAsync(DocumentAssignable query, boolean singleDelete, Durability durability) throws MongoDbException
query
- Query to locate the documents to be deleted.singleDelete
- If true then only a single document will be deleted. If
running in a sharded environment then this field must be false
or the query must contain the shard key.durability
- The durability for the delete.MongoDbException
- On an error deleting the documents.Future<Long> deleteAsync(DocumentAssignable query, Durability durability) throws MongoDbException
query
- Query to locate the documents to be deleted.durability
- The durability for the delete.MongoDbException
- On an error deleting the documents.ArrayElement distinct(Distinct command) throws MongoDbException
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.ArrayElement distinct(Distinct.Builder command) throws MongoDbException
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.void distinctAsync(Callback<ArrayElement> results, Distinct command) throws MongoDbException
results
- Callback for the distinct results returned.command
- The details of the distinct request.MongoDbException
- On an error finding the documents.void distinctAsync(Callback<ArrayElement> results, Distinct.Builder command) throws MongoDbException
results
- Callback for the distinct results returned.command
- The details of the distinct request.MongoDbException
- On an error finding the documents.Future<ArrayElement> distinctAsync(Distinct command) throws MongoDbException
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.Future<ArrayElement> distinctAsync(Distinct.Builder command) throws MongoDbException
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.boolean drop() throws MongoDbException
MongoDbException
- On an error dropping the collection.boolean dropIndex(IntegerElement... keys) throws MongoDbException
This method is intended to be used with the
Index
class's static methods:
import static
com.allanbank.mongodb.builder.Index.asc
; import staticcom.allanbank.mongodb.builder.Index.desc
; MongoCollection collection = ...; collection.dropIndex( asc("f"), desc("g") ); ...
keys
- The keys for the index to be dropped.MongoDbException
- On an error deleting the indexes.boolean dropIndex(String name) throws MongoDbException
name
- The name of the index.MongoDbException
- On an error deleting the indexes.Document explain(DocumentAssignable query) throws MongoDbException
query
- The query document.MongoDbException
- On an error finding the documents.Document explain(Find query) throws MongoDbException
This is equivalent to calling explainAsync(...).get()
query
- The query details.MongoDbException
- On an error finding the documents.Document explain(Find.Builder query) throws MongoDbException
This is equivalent to calling explainAsync(...).get()
query
- The query details.MongoDbException
- On an error finding the documents.void explainAsync(Callback<Document> results, Find query) throws MongoDbException
query
- The query details.results
- Callback that will be notified of the results of the explain.MongoDbException
- On an error finding the documents.void explainAsync(Callback<Document> results, Find.Builder query) throws MongoDbException
query
- The query details.results
- Callback that will be notified of the results of the explain.MongoDbException
- On an error finding the documents.Future<Document> explainAsync(Find query) throws MongoDbException
query
- The query details.MongoDbException
- On an error finding the documents.Future<Document> explainAsync(Find.Builder query) throws MongoDbException
query
- The query details.MongoDbException
- On an error finding the documents.MongoIterator<Document> find(DocumentAssignable query) throws MongoDbException
This is equivalent to calling findAsync(...).get()
query
- The query document.MongoDbException
- On an error finding the documents.MongoIterator<Document> find(Find query) throws MongoDbException
This is equivalent to calling findAsync(...).get()
query
- The query details.MongoDbException
- On an error finding the documents.MongoIterator<Document> find(Find.Builder query) throws MongoDbException
This is equivalent to calling findAsync(...).get()
query
- The query details.MongoDbException
- On an error finding the documents.Document findAndModify(FindAndModify command) throws MongoDbException
command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.Document findAndModify(FindAndModify.Builder command) throws MongoDbException
command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.void findAndModifyAsync(Callback<Document> results, FindAndModify command) throws MongoDbException
results
- Callback for the the found document.command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.void findAndModifyAsync(Callback<Document> results, FindAndModify.Builder command) throws MongoDbException
results
- Callback for the the found document.command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.Future<Document> findAndModifyAsync(FindAndModify command) throws MongoDbException
command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.Future<Document> findAndModifyAsync(FindAndModify.Builder command) throws MongoDbException
command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.void findAsync(Callback<MongoIterator<Document>> results, DocumentAssignable query) throws MongoDbException
results
- Callback that will be notified of the results of the query.query
- The query document.MongoDbException
- On an error finding the documents.void findAsync(Callback<MongoIterator<Document>> results, Find query) throws MongoDbException
results
- Callback that will be notified of the results of the query.query
- The query details.MongoDbException
- On an error finding the documents.void findAsync(Callback<MongoIterator<Document>> results, Find.Builder query) throws MongoDbException
results
- Callback that will be notified of the results of the query.query
- The query details.MongoDbException
- On an error finding the documents.Future<MongoIterator<Document>> findAsync(DocumentAssignable query) throws MongoDbException
query
- The query document.MongoDbException
- On an error finding the documents.Future<MongoIterator<Document>> findAsync(Find query) throws MongoDbException
query
- The query details.MongoDbException
- On an error finding the documents.Future<MongoIterator<Document>> findAsync(Find.Builder query) throws MongoDbException
query
- The query details.MongoDbException
- On an error finding the documents.Document findOne(DocumentAssignable query) throws MongoDbException
query
- The query document.MongoDbException
- On an error finding the document.Document findOne(Find query) throws MongoDbException
Note that following options in the Find
class do not make sense
and are silently ignored by this method.
Batch Size
- Automatically set to 1.Limit
- Automatically set to 1.Tailable
- This method only returns 1
document.query
- The query details.MongoDbException
- On an error finding the document.Document findOne(Find.Builder query) throws MongoDbException
Note that following options in the Find
class do not make sense
and are silently ignored by this method.
Batch Size
- Automatically set to 1.Limit
- Automatically set to 1.Tailable
- This method only returns 1
document.query
- The query details.MongoDbException
- On an error finding the document.void findOneAsync(Callback<Document> results, DocumentAssignable query) throws MongoDbException
results
- Callback that will be notified of the results of the query.query
- The query document.MongoDbException
- On an error finding the document.void findOneAsync(Callback<Document> results, Find query) throws MongoDbException
Note that following options in the Find
class do not make sense
and are silently ignored by this method.
Batch Size
- Automatically set to 1.Limit
- Automatically set to 1.Tailable
- This method only returns 1
document.results
- Callback that will be notified of the results of the query.query
- The query details.MongoDbException
- On an error finding the document.void findOneAsync(Callback<Document> results, Find.Builder query) throws MongoDbException
Note that following options in the Find
class do not make sense
and are silently ignored by this method.
Batch Size
- Automatically set to 1.Limit
- Automatically set to 1.Tailable
- This method only returns 1
document.results
- Callback that will be notified of the results of the query.query
- The query details.MongoDbException
- On an error finding the document.Future<Document> findOneAsync(DocumentAssignable query) throws MongoDbException
query
- The query document.MongoDbException
- On an error finding the document.Future<Document> findOneAsync(Find query) throws MongoDbException
Note that following options in the Find
class do not make sense
and are silently ignored by this method.
Batch Size
- Automatically set to 1.Limit
- Automatically set to 1.Tailable
- This method only returns 1
document.query
- The query details.MongoDbException
- On an error finding the document.Future<Document> findOneAsync(Find.Builder query) throws MongoDbException
Note that following options in the Find
class do not make sense
and are silently ignored by this method.
Batch Size
- Automatically set to 1.Limit
- Automatically set to 1.Tailable
- This method only returns 1
document.query
- The query details.MongoDbException
- On an error finding the document.String getDatabaseName()
Durability getDurability()
MongoCollection
instance.
Defaults to the Durability
from the parent MongoDatabase
instance.
MongoDatabase.getDurability()
String getName()
ReadPreference getReadPreference()
MongoCollection
instance.
Defaults to ReadPreference
from the parent MongoDatabase
instance.
MongoDatabase.getReadPreference()
ArrayElement groupBy(GroupBy command) throws MongoDbException
command
- The details of the group request.MongoDbException
- On an error finding the documents.ArrayElement groupBy(GroupBy.Builder command) throws MongoDbException
command
- The details of the group request.MongoDbException
- On an error finding the documents.void groupByAsync(Callback<ArrayElement> results, GroupBy command) throws MongoDbException
results
- Callback for the group results returned.command
- The details of the group request.MongoDbException
- On an error finding the documents.void groupByAsync(Callback<ArrayElement> results, GroupBy.Builder command) throws MongoDbException
results
- Callback for the group results returned.command
- The details of the group request.MongoDbException
- On an error finding the documents.Future<ArrayElement> groupByAsync(GroupBy command) throws MongoDbException
command
- The details of the group request.MongoDbException
- On an error finding the documents.Future<ArrayElement> groupByAsync(GroupBy.Builder command) throws MongoDbException
command
- The details of the group request.MongoDbException
- On an error finding the documents.int insert(boolean continueOnError, DocumentAssignable... documents) throws MongoDbException
This is equivalent to calling
insertAsync(...).get()
continueOnError
- If the insert should continue if one of the documents causes
an error.documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.int insert(boolean continueOnError, Durability durability, DocumentAssignable... documents) throws MongoDbException
This is equivalent to calling
insertAsync(...).get()
continueOnError
- If the insert should continue if one of the documents causes
an error.durability
- The durability for the insert.documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.int insert(DocumentAssignable... documents) throws MongoDbException
This is equivalent to calling
insertAsync(...).get()
documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.int insert(Durability durability, DocumentAssignable... documents) throws MongoDbException
This is equivalent to calling
insertAsync(...).get()
durability
- The durability for the insert.documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.Future<Integer> insertAsync(boolean continueOnError, DocumentAssignable... documents) throws MongoDbException
continueOnError
- If the insert should continue if one of the documents causes
an error.documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.Future<Integer> insertAsync(boolean continueOnError, Durability durability, DocumentAssignable... documents) throws MongoDbException
continueOnError
- If the insert should continue if one of the documents causes
an error.durability
- The durability for the insert.documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.void insertAsync(Callback<Integer> results, boolean continueOnError, DocumentAssignable... documents) throws MongoDbException
results
- Callback
that will be notified with the results of the
insert. Currently, the value is always zero. Once SERVER-4381 is fixed then expected to be the number of
documents inserted. If the durability is NONE then returns
-1
.continueOnError
- If the insert should continue if one of the documents causes
an error.documents
- The documents to add to the collection.MongoDbException
- On an error inserting the documents.void insertAsync(Callback<Integer> results, boolean continueOnError, Durability durability, DocumentAssignable... documents) throws MongoDbException
results
- Callback
that will be notified with the results of the
insert. Currently, the value is always zero. Once SERVER-4381 is fixed then expected to be the number of
documents inserted. If the durability is NONE then returns
-1
.continueOnError
- If the insert should continue if one of the documents causes
an error.durability
- The durability for the insert.documents
- The documents to add to the collection.MongoDbException
- On an error inserting the documents.void insertAsync(Callback<Integer> results, DocumentAssignable... documents) throws MongoDbException
results
- Callback
that will be notified with the results of the
insert. Currently, the value is always zero. Once SERVER-4381 is fixed then expected to be the number of
documents inserted. If the durability is NONE then returns
-1
.documents
- The documents to add to the collection.MongoDbException
- On an error inserting the documents.void insertAsync(Callback<Integer> results, Durability durability, DocumentAssignable... documents) throws MongoDbException
results
- Callback
that will be notified with the results of the
insert. Currently, the value is always zero. Once SERVER-4381 is fixed then expected to be the number of
documents inserted. If the durability is NONE then returns
-1
.durability
- The durability for the insert.documents
- The documents to add to the collection.MongoDbException
- On an error inserting the documents.Future<Integer> insertAsync(DocumentAssignable... documents) throws MongoDbException
documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.Future<Integer> insertAsync(Durability durability, DocumentAssignable... documents) throws MongoDbException
durability
- The durability for the insert.documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.boolean isCapped() throws MongoDbException
statistics
indicate that
the collection is a capped collection.statistics
indicate that
the collection is a capped collection.MongoDbException
- On an error collecting the collection statistics.List<Document> mapReduce(MapReduce command) throws MongoDbException
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.List<Document> mapReduce(MapReduce.Builder command) throws MongoDbException
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.void mapReduceAsync(Callback<List<Document>> results, MapReduce command) throws MongoDbException
results
- Callback for the map/reduce results returned. Note this might
be empty if the output type is not inline.command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.void mapReduceAsync(Callback<List<Document>> results, MapReduce.Builder command) throws MongoDbException
results
- Callback for the map/reduce results returned. Note this might
be empty if the output type is not inline.command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.Future<List<Document>> mapReduceAsync(MapReduce command) throws MongoDbException
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.Future<List<Document>> mapReduceAsync(MapReduce.Builder command) throws MongoDbException
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.int save(DocumentAssignable document) throws MongoDbException
document
to the collection.
If the document
does not contain an _id
field then this
method is equivalent to: insert(document)
.
If the document
does contain an _id
field then this
method is equivalent to:
update(BuilderFactory.start().add(document.get("_id")), document, false,
true)
.
document
- The document to save to the collection.MongoDbException
- On an error saving the documents.int save(DocumentAssignable document, Durability durability) throws MongoDbException
document
to the collection.
If the document
does not contain an _id
field then this
method is equivalent to:
insert(durability,
document)
.
If the document
does contain an _id
field then this
method is equivalent to:
update(BuilderFactory.start().add(document.get("_id")), document, false,
true, durability)
.
document
- The document to save to the collection.durability
- The durability for the save.MongoDbException
- On an error saving the documents.void saveAsync(Callback<Integer> results, DocumentAssignable document) throws MongoDbException
document
to the collection.
If the document
does not contain an _id
field then this
method is equivalent to:
insertAsync(results,
document)
.
If the document
does contain an _id
field then this
method is equivalent to:
updateAsync(results, BuilderFactory.start().add(document.get("_id")),
document, false, true)
.
results
- Callback
that will be notified with the results of the
insert. If the durability of the operation is NONE then this
will be -1.document
- The document to save to the collection.MongoDbException
- On an error saving the documents.void saveAsync(Callback<Integer> results, DocumentAssignable document, Durability durability) throws MongoDbException
document
to the collection.
If the document
does not contain an _id
field then this
method is equivalent to:
insertAsync(results, durability, document)
.
If the document
does contain an _id
field then this
method is equivalent to:
updateAsync(results, BuilderFactory.start().add(document.get("_id")),
document, false, true, durability)
.
results
- Callback
that will be notified with the results of the
insert. If the durability of the operation is NONE then this
will be -1.document
- The document to save to the collection.durability
- The durability for the save.MongoDbException
- On an error saving the documents.Future<Integer> saveAsync(DocumentAssignable document) throws MongoDbException
document
to the collection.
If the document
does not contain an _id
field then this
method is equivalent to: insertAsync(document)
.
If the document
does contain an _id
field then this
method is equivalent to:
updateAsync(BuilderFactory.start().add(document.get("_id")), document,
false, true)
.
document
- The document to save to the collection.MongoDbException
- On an error saving the documents.Future<Integer> saveAsync(DocumentAssignable document, Durability durability) throws MongoDbException
document
to the collection.
If the document
does not contain an _id
field then this
method is equivalent to:
insertAsync(durability, document)
.
If the document
does contain an _id
field then this
method is equivalent to:
updateAsync(BuilderFactory.start().add(document.get("_id")), document,
false, true, durability)
.
document
- The document to save to the collection.durability
- The durability for the save.MongoDbException
- On an error saving the documents.void setDurability(Durability durability)
MongoCollection
instance.
Defaults to the Durability
from the parent MongoDatabase
instance if set to null
.
durability
- The durability for write operations on the server.MongoDatabase.getDurability()
void setReadPreference(ReadPreference readPreference)
MongoCollection
instance.
Defaults to the ReadPreference
from the parent
MongoDatabase
instance if set to null
.
readPreference
- The read preference for a query.MongoDatabase.getReadPreference()
Document stats() throws MongoDbException
MongoDbException
- On an error collecting the collection statistics.@Deprecated MongoCursorControl streamingFind(Callback<Document> results, DocumentAssignable query) throws MongoDbException
streamingFind(StreamCallback, DocumentAssignable)
method instead. This method will be removed after the 1.3.0
release.
The sequence of callbacks will be terminated by either calling the
results.callback(...)
method with
null
or by calling the results.exception(...)
method on an error.
Applications can terminate the stream by throwing a
RuntimeException
from the Callback.callback(V)
method (which
will then call the Callback.exception(java.lang.Throwable)
method).
Only a single thread will invoke the callback at a time but that thread may change over time.
If the callback processing requires any significant time (including I/O)
it is recommended that an
Executor
be configured within the MongoClientConfiguration
to
off-load the processing from the receive thread.
results
- Callback that will be notified of the results of the query.query
- The query document.MongoCursorControl
to control the cursor streaming
documents to the caller. This includes the ability to stop the
cursor and persist its state.MongoDbException
- On an error finding the documents.@Deprecated MongoCursorControl streamingFind(Callback<Document> results, Find query) throws MongoDbException
streamingFind(StreamCallback, Find)
method
instead. This method will be removed after the 1.3.0 release.
The sequence of callbacks will be terminated by either calling the
results.callback(...)
method with
null
or by calling the results.exception(...)
method on an error.
Applications can terminate the stream by throwing a
RuntimeException
from the Callback.callback(V)
method (which
will then call the Callback.exception(java.lang.Throwable)
method).
Only a single thread will invoke the callback at a time but that thread may change over time.
If the callback processing requires any significant time (including I/O)
it is recommended that an
Executor
be configured within the MongoClientConfiguration
to
off-load the processing from the receive thread.
results
- Callback that will be notified of the results of the query.query
- The query details.MongoCursorControl
to control the cursor streaming
documents to the caller. This includes the ability to stop the
cursor and persist its state.MongoDbException
- On an error finding the documents.MongoCursorControl streamingFind(StreamCallback<Document> results, DocumentAssignable query) throws MongoDbException
The sequence of callbacks will be terminated by either calling the
results.done()
method or by calling the
results.exception(...)
method
(in the event of an error).
Applications can terminate the stream by throwing a
RuntimeException
from the Callback.callback(V)
method
(which will then call the Callback.exception(java.lang.Throwable)
method or by
closing the MongoCursorControl
returned from this method.
Only a single thread will invoke the callback at a time but that thread may change over time.
If the callback processing requires any significant time (including I/O)
it is recommended that an
Executor
be configured within the MongoClientConfiguration
to
off-load the processing from the receive thread.
results
- Callback that will be notified of the results of the query.query
- The query document.MongoCursorControl
to control the cursor streaming
documents to the caller. This includes the ability to stop the
cursor and persist its state.MongoDbException
- On an error finding the documents.MongoCursorControl streamingFind(StreamCallback<Document> results, Find query) throws MongoDbException
The sequence of callbacks will be terminated by either calling the
results.done()
method or by calling the
results.exception(...)
method
(in the event of an error).
Applications can terminate the stream by throwing a
RuntimeException
from the Callback.callback(V)
method
(which will then call the Callback.exception(java.lang.Throwable)
method or by
closing the MongoCursorControl
returned from this method.
Only a single thread will invoke the callback at a time but that thread may change over time.
If the callback processing requires any significant time (including I/O)
it is recommended that an
Executor
be configured within the MongoClientConfiguration
to
off-load the processing from the receive thread.
results
- Callback that will be notified of the results of the query.query
- The query details.MongoCursorControl
to control the cursor streaming
documents to the caller. This includes the ability to stop the
cursor and persist its state.MongoDbException
- On an error finding the documents.MongoCursorControl streamingFind(StreamCallback<Document> results, Find.Builder query) throws MongoDbException
The sequence of callbacks will be terminated by either calling the
results.done()
method or by calling the
results.exception(...)
method
(in the event of an error).
Applications can terminate the stream by throwing a
RuntimeException
from the Callback.callback(V)
method
(which will then call the Callback.exception(java.lang.Throwable)
method or by
closing the MongoCursorControl
returned from this method.
Only a single thread will invoke the callback at a time but that thread may change over time.
If the callback processing requires any significant time (including I/O)
it is recommended that an
Executor
be configured within the MongoClientConfiguration
to
off-load the processing from the receive thread.
results
- Callback that will be notified of the results of the query.query
- The query details.MongoCursorControl
to control the cursor streaming
documents to the caller. This includes the ability to stop the
cursor and persist its state.MongoDbException
- On an error finding the documents.List<TextResult> textSearch(Text command) throws MongoDbException
text
command on the server.command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.List<TextResult> textSearch(Text.Builder command) throws MongoDbException
text
command on the server.command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.void textSearchAsync(Callback<List<TextResult>> results, Text command) throws MongoDbException
text
command on the server.results
- Callback for the text
results returned.command
- The details of the text
request.MongoDbException
- On an error executing the text
command.void textSearchAsync(Callback<List<TextResult>> results, Text.Builder command) throws MongoDbException
text
command on the server.results
- Callback for the text
results returned.command
- The details of the text
request.MongoDbException
- On an error executing the text
command.Future<List<TextResult>> textSearchAsync(Text command) throws MongoDbException
text
command on the server.command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.Future<List<TextResult>> textSearchAsync(Text.Builder command) throws MongoDbException
text
command on the server.command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.long update(DocumentAssignable query, DocumentAssignable update) throws MongoDbException
query
- The query to select the documents to update.update
- The updates to apply to the selected documents.MongoDbException
- On an error updating the documents.long update(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert) throws MongoDbException
query
- The query to select the documents to update.update
- The updates to apply to the selected documents.multiUpdate
- If true then the update is applied to all of the matching
documents, otherwise only the first document found is updated.upsert
- If true then if no document is found then a new document is
created and updated, otherwise no operation is performed.MongoDbException
- On an error updating the documents.long update(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert, Durability durability) throws MongoDbException
query
- The query to select the documents to update.update
- The updates to apply to the selected documents.multiUpdate
- If true then the update is applied to all of the matching
documents, otherwise only the first document found is updated.upsert
- If true then if no document is found then a new document is
created and updated, otherwise no operation is performed.durability
- The durability for the insert.MongoDbException
- On an error updating the documents.long update(DocumentAssignable query, DocumentAssignable update, Durability durability) throws MongoDbException
query
- The query to select the documents to update.update
- The updates to apply to the selected documents.durability
- The durability for the update.MongoDbException
- On an error updating the documents.void updateAsync(Callback<Long> results, DocumentAssignable query, DocumentAssignable update) throws MongoDbException
results
- The Callback
that will be notified of the number of
documents updated. If the durability of the operation is NONE
then this will be -1.query
- The query to select the documents to update.update
- The updates to apply to the selected documents.MongoDbException
- On an error updating the documents.void updateAsync(Callback<Long> results, DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert) throws MongoDbException
results
- The Callback
that will be notified of the number of
documents updated. If the durability of the operation is NONE
then this will be -1.query
- The query to select the documents to update.update
- The updates to apply to the selected documents.multiUpdate
- If true then the update is applied to all of the matching
documents, otherwise only the first document found is updated.upsert
- If true then if no document is found then a new document is
created and updated, otherwise no operation is performed.MongoDbException
- On an error updating the documents.void updateAsync(Callback<Long> results, DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert, Durability durability) throws MongoDbException
results
- The Callback
that will be notified of the number of
documents updated. If the durability of the operation is NONE
then this will be -1.query
- The query to select the documents to update.update
- The updates to apply to the selected documents.multiUpdate
- If true then the update is applied to all of the matching
documents, otherwise only the first document found is updated.upsert
- If true then if no document is found then a new document is
created and updated, otherwise no operation is performed.durability
- The durability for the update.MongoDbException
- On an error updating the documents.void updateAsync(Callback<Long> results, DocumentAssignable query, DocumentAssignable update, Durability durability) throws MongoDbException
results
- The Callback
that will be notified of the number of
documents updated. If the durability of the operation is NONE
then this will be -1.query
- The query to select the documents to update.update
- The updates to apply to the selected documents.durability
- The durability for the update.MongoDbException
- On an error updating the documents.Future<Long> updateAsync(DocumentAssignable query, DocumentAssignable update) throws MongoDbException
query
- The query to select the documents to update.update
- The updates to apply to the selected documents.Future
that will be updated with the number of
documents updated. If the durability of the operation is NONE
then this will be -1.MongoDbException
- On an error updating the documents.Future<Long> updateAsync(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert) throws MongoDbException
query
- The query to select the documents to update.update
- The updates to apply to the selected documents.multiUpdate
- If true then the update is applied to all of the matching
documents, otherwise only the first document found is updated.upsert
- If true then if no document is found then a new document is
created and updated, otherwise no operation is performed.Future
that will be updated with the number of
documents updated. If the durability of the operation is NONE
then this will be -1.MongoDbException
- On an error updating the documents.Future<Long> updateAsync(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert, Durability durability) throws MongoDbException
query
- The query to select the documents to update.update
- The updates to apply to the selected documents.multiUpdate
- If true then the update is applied to all of the matching
documents, otherwise only the first document found is updated.upsert
- If true then if no document is found then a new document is
created and updated, otherwise no operation is performed.durability
- The durability for the update.Future
that will be updated with the number of
documents updated. If the durability of the operation is NONE
then this will be -1.MongoDbException
- On an error updating the documents.Future<Long> updateAsync(DocumentAssignable query, DocumentAssignable update, Durability durability) throws MongoDbException
query
- The query to select the documents to update.update
- The updates to apply to the selected documents.durability
- The durability for the update.Future
that will be updated with the number of
documents updated. If the durability of the operation is NONE
then this will be -1.MongoDbException
- On an error updating the documents.Document updateOptions(DocumentAssignable options) throws MongoDbException
collMod
command. The return value is the response from the MongoDB server and
normally contains a <name>_old
field for each
successfully set option on the collection. MongoCollection collection = ...; collection.updateOptions( BuilderFactory.start().add( "usePowerOf2Sizes", true ) );
options
- The collection options to be set.MongoDbException
- On an error validating the collection.Document validate(MongoCollection.ValidateMode mode) throws MongoDbException
mode
- The validation mode to use.MongoDbException
- On an error validating the collection.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.