public interface MongoCollection extends AsyncMongoCollection
The asynchronous methods for interacting with a collection are declared as
part of the AsyncMongoCollection
interface (which this interface
extends. The separation of the interfaces is to support the ability to batch
requests to the server. This will take advantage of the batched write
commands if the driver is only connected to @link 2.6
or above servers otherwise batching is similar in function to the
serialized client
capability.
To use the batching capability you will need to call the
startBatch()
method and then ensure that the
close()
method is called to
submit the batch of requests.
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.
|
static Document |
NONE
An (empty) update document to perform no actual modifications.
|
Modifier and Type | Method and Description |
---|---|
MongoIterator<Document> |
aggregate(Aggregate.Builder command)
Invokes a aggregate command on the server.
|
MongoIterator<Document> |
aggregate(Aggregate command)
Invokes a aggregate command on the server.
|
long |
count()
Counts the set of documents in the collection.
|
long |
count(Count.Builder count)
Counts the set of documents matching the query document in the
collection.
|
long |
count(Count count)
Counts the set of documents matching the query document 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.
|
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.
|
MongoIterator<Element> |
distinct(Distinct.Builder command)
Invokes a distinct command on the server.
|
MongoIterator<Element> |
distinct(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.
|
boolean |
exists()
Returns true if this collection already exists on the server.
|
Document |
explain(Aggregate.Builder aggregation)
Explains the way that the aggregation will be performed.
|
Document |
explain(Aggregate aggregation)
Explains the way that the aggregation will be performed.
|
Document |
explain(DocumentAssignable query)
Explains the way that the query will be performed.
|
Document |
explain(Find.Builder query)
Explains the way that the query will be performed.
|
Document |
explain(Find query)
Explains the way that the query 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.
|
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.
|
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. |
MongoIterator<Element> |
groupBy(GroupBy.Builder command)
Invokes a group command on the server.
|
MongoIterator<Element> |
groupBy(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.
|
boolean |
isCapped()
Returns true if the collection
statistics indicate that
the collection is a capped collection. |
MongoIterator<Document> |
mapReduce(MapReduce.Builder command)
Invokes a mapReduce command on the server.
|
MongoIterator<Document> |
mapReduce(MapReduce command)
Invokes a mapReduce command on the server.
|
Collection<MongoIterator<Document>> |
parallelScan(ParallelScan.Builder parallelScan)
Uses the
parallelCollectionScan command to open multiple
iterators over the collection each configured to scan a distinct regions
of the collection. |
Collection<MongoIterator<Document>> |
parallelScan(ParallelScan parallelScan)
Uses the
parallelCollectionScan command to open multiple
iterators over the collection each configured to scan a distinct regions
of the collection. |
int |
save(DocumentAssignable document)
Saves the
document to the collection. |
int |
save(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. |
BatchedAsyncMongoCollection |
startBatch()
Starts a batch of requests to the server.
|
Document |
stats()
Returns the statistics for the collection.
|
MongoIterator<TextResult> |
textSearch(Text.Builder command)
Deprecated.
Support for the
text command was deprecated in the
2.6 version of MongoDB. Use the
$text query operator
instead. This method will not be removed until two releases
after the MongoDB 2.6 release (e.g. 2.10 if the releases are
2.8 and 2.10). |
MongoIterator<TextResult> |
textSearch(Text command)
Deprecated.
Support for the
text command was deprecated in the
2.6 version of MongoDB. Use the
$text query operator
instead. This method will not be removed until two releases
after the MongoDB 2.6 release (e.g. 2.10 if the releases are
2.8 and 2.10). |
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.
|
Document |
updateOptions(DocumentAssignable options)
Updates the collection's options or flags using the
collMod
command. |
Document |
validate(MongoCollection.ValidateMode mode)
Validates the collections contents.
|
long |
write(BatchedWrite.Builder write)
Constructs the appropriate set of write commands to send to the server.
|
long |
write(BatchedWrite write)
Constructs the appropriate set of write commands to send to the server.
|
aggregateAsync, aggregateAsync, aggregateAsync, aggregateAsync, aggregateAsync, aggregateAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, countAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, deleteAsync, distinctAsync, distinctAsync, distinctAsync, distinctAsync, distinctAsync, distinctAsync, explainAsync, explainAsync, explainAsync, explainAsync, explainAsync, explainAsync, explainAsync, explainAsync, explainAsync, explainAsync, explainAsync, explainAsync, findAndModifyAsync, findAndModifyAsync, findAndModifyAsync, findAndModifyAsync, findAndModifyAsync, findAndModifyAsync, findAsync, findAsync, findAsync, findAsync, findAsync, findAsync, findAsync, findAsync, findAsync, findOneAsync, findOneAsync, findOneAsync, findOneAsync, findOneAsync, findOneAsync, findOneAsync, findOneAsync, findOneAsync, groupByAsync, groupByAsync, groupByAsync, groupByAsync, groupByAsync, groupByAsync, insertAsync, insertAsync, insertAsync, insertAsync, insertAsync, insertAsync, insertAsync, insertAsync, insertAsync, insertAsync, insertAsync, insertAsync, mapReduceAsync, mapReduceAsync, mapReduceAsync, mapReduceAsync, mapReduceAsync, mapReduceAsync, parallelScanAsync, parallelScanAsync, parallelScanAsync, parallelScanAsync, parallelScanAsync, parallelScanAsync, saveAsync, saveAsync, saveAsync, saveAsync, saveAsync, saveAsync, stream, stream, stream, stream, stream, stream, stream, stream, streamingFind, streamingFind, streamingFind, streamingFind, streamingFind, streamingFind, textSearchAsync, textSearchAsync, textSearchAsync, textSearchAsync, updateAsync, updateAsync, updateAsync, updateAsync, updateAsync, updateAsync, updateAsync, updateAsync, updateAsync, updateAsync, updateAsync, updateAsync, writeAsync, writeAsync, writeAsync, writeAsync, writeAsync, writeAsync
static final Document ALL
static final Document NONE
MongoIterator<Document> aggregate(Aggregate command) throws MongoDbException
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.MongoIterator<Document> aggregate(Aggregate.Builder command) throws MongoDbException
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(Count count) throws MongoDbException
count
- The count command.MongoDbException
- On an error counting the documents.long count(Count.Builder count) throws MongoDbException
count
- The count command.MongoDbException
- On an error counting 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.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.MongoIterator<Element> distinct(Distinct command) throws MongoDbException
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.MongoIterator<Element> distinct(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.boolean exists() throws MongoDbException
This method is simply a helper name to check if this collection's name
appears in the parent database's
list of
collections.
MongoDbException
- On an error retrieving the list of collections.Document explain(Aggregate aggregation) throws MongoDbException
This is equivalent to calling explainAsync(...).get()
aggregation
- The aggregation details.MongoDbException
- On an error finding the documents.Document explain(Aggregate.Builder aggregation) throws MongoDbException
This is equivalent to calling explainAsync(...).get()
aggregation
- The aggregation details.MongoDbException
- On an error finding the documents.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.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.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.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()
MongoIterator<Element> groupBy(GroupBy command) throws MongoDbException
command
- The details of the group request.MongoDbException
- On an error finding the documents.MongoIterator<Element> groupBy(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.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.MongoIterator<Document> mapReduce(MapReduce command) throws MongoDbException
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.MongoIterator<Document> mapReduce(MapReduce.Builder command) throws MongoDbException
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.Collection<MongoIterator<Document>> parallelScan(ParallelScan parallelScan) throws MongoDbException
parallelCollectionScan
command to open multiple
iterators over the collection each configured to scan a distinct regions
of the collection. You may then use a separate thread to scan each region
of the collection in parallel.parallelScan
- The details on the scan.MongoDbException
- On an error initializing the parallel scan.Collection<MongoIterator<Document>> parallelScan(ParallelScan.Builder parallelScan) throws MongoDbException
parallelCollectionScan
command to open multiple
iterators over the collection each configured to scan a distinct regions
of the collection. You may then use a separate thread to scan each region
of the collection in parallel.parallelScan
- The details on the scan.MongoDbException
- On an error initializing the parallel scan.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 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()
BatchedAsyncMongoCollection startBatch()
BatchedAsyncMongoCollection.close()
method must be called
to submit the batch of requests.Document stats() throws MongoDbException
MongoDbException
- On an error collecting the collection statistics.@Deprecated MongoIterator<TextResult> textSearch(Text command) throws MongoDbException
text
command was deprecated in the
2.6 version of MongoDB. Use the
$text
query operator
instead. This method will not be removed until two releases
after the MongoDB 2.6 release (e.g. 2.10 if the releases are
2.8 and 2.10).text
command on the server.command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.@Deprecated MongoIterator<TextResult> textSearch(Text.Builder command) throws MongoDbException
text
command was deprecated in the
2.6 version of MongoDB. Use the
$text
query operator
instead. This method will not be removed until two releases
after the MongoDB 2.6 release (e.g. 2.10 if the releases are
2.8 and 2.10).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.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.long write(BatchedWrite write) throws MongoDbException
If connected to a cluster where all servers can accept write commands then the operations will be sent to the server using the write commands. If the cluster does not support the write command then the operations will be converted to a series of native write operations.
Since this method may use the write commands a Durability
of
Durability.NONE
will be changed to Durability.ACK
.
write
- The batched writesreturn
for the insert(DocumentAssignable...)
method applies.MongoDbException
- On an error submitting the write operations.BatchedWrite.REQUIRED_VERSION
long write(BatchedWrite.Builder write) throws MongoDbException
If connected to a cluster where all servers can accept write commands then the operations will be sent to the server using the write commands. If the cluster does not support the write command then the operations will be converted to a series of native write operations.
Since this method may use the write commands a Durability
of
Durability.NONE
will be changed to Durability.ACK
.
write
- The batched writesreturn
for the insert(DocumentAssignable...)
method applies.MongoDbException
- On an error submitting the write operations.BatchedWrite.REQUIRED_VERSION
Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.