public abstract class AbstractMongoCollection extends Object implements MongoCollection
This class keeps the clutter in the derived class to a minimum and also deals with the conversion of the asynchronous method invocations into synchronous methods for those uses cases that do not require an asynchronous interface.
MongoCollection.ValidateMode
Modifier and Type | Field and Description |
---|---|
static boolean |
DELETE_SINGLE_DELETE_DEFAULT
The default for if a delete should only delete the first document it
matches.
|
static Document |
EMPTY_INDEX_OPTIONS
The default empty index options.
|
static boolean |
INSERT_CONTINUE_ON_ERROR_DEFAULT
The default for if an insert should continue on an error.
|
protected Client |
myClient
The client for interacting with MongoDB.
|
protected MongoDatabase |
myDatabase
The name of the database we interact with.
|
protected String |
myName
The name of the collection we interact with.
|
static Document |
UNIQUE_INDEX_OPTIONS
The default for a UNIQUE index options.
|
static boolean |
UPDATE_MULTIUPDATE_DEFAULT
The default for doing a multiple-update on an update.
|
static boolean |
UPDATE_UPSERT_DEFAULT
The default for doing an upsert on an update.
|
ALL
Constructor and Description |
---|
AbstractMongoCollection(Client client,
MongoDatabase database,
String name)
Create a new AbstractMongoCollection.
|
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.
|
abstract void |
aggregateAsync(Callback<List<Document>> results,
Aggregate command)
Invokes a aggregate command on the server.
|
protected GetLastError |
asGetLastError(Durability durability)
Converts the
Durability into a GetLastError command. |
protected String |
buildIndexName(Element... keys)
Generates a name for the index based on the keys.
|
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.
|
abstract 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.
|
abstract 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.
|
abstract 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.
|
abstract 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 |
dropIndex(IntegerElement... keys)
Deletes the indexes matching the keys specified.
|
abstract 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.
|
abstract 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.
|
abstract 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.
|
abstract 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)
Overridden to call the
findOneAsync(Callback, Find) . |
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.
|
abstract 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.
|
abstract 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.
|
abstract 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.
|
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.
|
abstract 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. |
abstract 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. |
MongoCursorControl |
streamingFind(Callback<Document> results,
DocumentAssignable query)
Deprecated.
|
MongoCursorControl |
streamingFind(Callback<Document> results,
Find query)
Deprecated.
|
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.
|
abstract 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. |
abstract 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.
|
abstract 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
drop, isCapped, stats, updateOptions, validate
public static final boolean DELETE_SINGLE_DELETE_DEFAULT
public static final Document EMPTY_INDEX_OPTIONS
public static final boolean INSERT_CONTINUE_ON_ERROR_DEFAULT
public static final Document UNIQUE_INDEX_OPTIONS
public static final boolean UPDATE_MULTIUPDATE_DEFAULT
public static final boolean UPDATE_UPSERT_DEFAULT
protected final Client myClient
protected final MongoDatabase myDatabase
protected final String myName
public AbstractMongoCollection(Client client, MongoDatabase database, String name)
client
- The client for interacting with MongoDB.database
- The database we interact with.name
- The name of the collection we interact with.public List<Document> aggregate(Aggregate command) throws MongoDbException
Overridden to call the aggregateAsync(Aggregate)
.
aggregate
in interface MongoCollection
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.aggregateAsync(Aggregate)
public List<Document> aggregate(Aggregate.Builder command) throws MongoDbException
Overridden to call the aggregate(Aggregate)
.
aggregate
in interface MongoCollection
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.public Future<List<Document>> aggregateAsync(Aggregate command) throws MongoDbException
Overridden to call the aggregateAsync(Callback, Aggregate)
.
aggregateAsync
in interface MongoCollection
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.aggregateAsync(Callback, Aggregate)
public Future<List<Document>> aggregateAsync(Aggregate.Builder command) throws MongoDbException
Overridden to call the aggregateAsync(Aggregate)
.
aggregateAsync
in interface MongoCollection
command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.public abstract void aggregateAsync(Callback<List<Document>> results, Aggregate command) throws MongoDbException
This is the canonical aggregate
method that implementations
must override.
aggregateAsync
in interface MongoCollection
results
- Callback for the aggregation results returned.command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.MongoCollection.aggregateAsync(Callback, Aggregate)
public void aggregateAsync(Callback<List<Document>> results, Aggregate.Builder command) throws MongoDbException
Overridden to call the aggregateAsync(Callback, Aggregate)
.
aggregateAsync
in interface MongoCollection
results
- Callback for the aggregation results returned.command
- The details of the aggregation request.MongoDbException
- On an error executing the aggregate command.public long count() throws MongoDbException
This is equivalent to calling countAsync().get()
Overridden to call the count(DocumentAssignable,ReadPreference)
method with getReadPreference()
as the readPreference
argument and an empty query
document.
count
in interface MongoCollection
MongoDbException
- On an error finding the documents.public long count(DocumentAssignable query) throws MongoDbException
This is equivalent to calling countAsync(...).get()
Overridden to call the count(DocumentAssignable, ReadPreference)
method with getReadPreference()
as the readPreference
argument.
count
in interface MongoCollection
query
- The query document.MongoDbException
- On an error finding the documents.public long count(DocumentAssignable query, ReadPreference readPreference) throws MongoDbException
Overridden to call the
countAsync(DocumentAssignable, ReadPreference)
method.
count
in interface MongoCollection
query
- The query document.readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.public long count(ReadPreference readPreference) throws MongoDbException
This is equivalent to calling countAsync().get()
Overridden to call the count(DocumentAssignable,ReadPreference)
method with an empty query
document.
count
in interface MongoCollection
readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.public Future<Long> countAsync() throws MongoDbException
This is equivalent to calling countAsync().get()
Overridden to call the
countAsync(DocumentAssignable,ReadPreference)
method with
getReadPreference()
as the readPreference argument and
an empty query
document.
countAsync
in interface MongoCollection
MongoDbException
- On an error finding the documents.public void countAsync(Callback<Long> results) throws MongoDbException
This is equivalent to calling
countAsync(results,
BuilderFactory.start())
Overridden to call the
countAsync(Callback,DocumentAssignable,ReadPreference)
method
with getReadPreference()
as the readPreference argument
and an empty query
document.
countAsync
in interface MongoCollection
results
- The callback to notify of the results.MongoDbException
- On an error finding the documents.public void countAsync(Callback<Long> results, DocumentAssignable query) throws MongoDbException
Overridden to call the
countAsync(Callback, DocumentAssignable, ReadPreference)
method
with getReadPreference()
as the readPreference
argument.
countAsync
in interface MongoCollection
results
- The callback to notify of the results.query
- The query document.MongoDbException
- On an error finding the documents.public abstract void countAsync(Callback<Long> results, DocumentAssignable query, ReadPreference readPreference) throws MongoDbException
This is the canonical count
method that implementations must
override.
countAsync
in interface MongoCollection
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.public void countAsync(Callback<Long> results, ReadPreference readPreference) throws MongoDbException
This is equivalent to calling
countAsync(results,
BuilderFactory.start(), readPreference)
Overridden to call the
countAsync(Callback,DocumentAssignable,ReadPreference)
method
with an empty query
document.
countAsync
in interface MongoCollection
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.public Future<Long> countAsync(DocumentAssignable query) throws MongoDbException
Overridden to call the
countAsync(Callback, DocumentAssignable, ReadPreference)
method
with getReadPreference()
as the readPreference
argument.
countAsync
in interface MongoCollection
query
- The query document.MongoDbException
- On an error finding the documents.public Future<Long> countAsync(DocumentAssignable query, ReadPreference readPreference) throws MongoDbException
Overridden to call the
countAsync(Callback, DocumentAssignable, ReadPreference)
method.
countAsync
in interface MongoCollection
query
- The query document.readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.public Future<Long> countAsync(ReadPreference readPreference) throws MongoDbException
This is equivalent to calling countAsync().get()
Overridden to call the
countAsync(DocumentAssignable,ReadPreference)
method with an
empty query
document.
countAsync
in interface MongoCollection
readPreference
- The preference for which servers to use to retrieve the
results.MongoDbException
- On an error finding the documents.public 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") ); ...
Overridden to call the createIndex(String, boolean, Element...)
method with null
for the name.
createIndex
in interface MongoCollection
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.createIndex(String, boolean, Element...)
public 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") ); ...
Overridden to call the
createIndex(String,DocumentAssignable,Element...)
method with
null
for name.
createIndex
in interface MongoCollection
options
- The options for the index.keys
- The keys to use for the index.MongoDbException
- On a failure building the index.createIndex(String,DocumentAssignable,Element...)
public 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") ); ...
Overridden to call the
createIndex(DocumentAssignable, Element...)
method with
EMPTY_INDEX_OPTIONS
for options.
createIndex
in interface MongoCollection
keys
- The keys to use for the index.MongoDbException
- On a failure building the index.createIndex(DocumentAssignable, Element...)
public 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") ); ...
Overridden to call the
createIndex(String,DocumentAssignable,Element...)
method with
UNIQUE_INDEX_OPTIONS
if unique
is true
or
EMPTY_INDEX_OPTIONS
id unique
is false
.
createIndex
in interface MongoCollection
name
- The name of the index. If null
then a name is
generated based on the keys.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.createIndex(String, DocumentAssignable, Element...)
public abstract 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") ); ...
This is the canonical createIndex
method that
implementations must override.
createIndex
in interface MongoCollection
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.MongoCollection.createIndex(String,DocumentAssignable,Element...)
public long delete(DocumentAssignable query) throws MongoDbException
Overridden to call the
delete(DocumentAssignable, boolean, Durability)
method with
false as the singleDelete argument and the
default durability
.
delete
in interface MongoCollection
query
- Query to locate the documents to be deleted.MongoDbException
- On an error deleting the documents.delete(DocumentAssignable, boolean, Durability)
public long delete(DocumentAssignable query, boolean singleDelete) throws MongoDbException
Overridden to call the
delete(DocumentAssignable, boolean, Durability)
method with the
default durability
.
delete
in interface MongoCollection
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.delete(DocumentAssignable, boolean, Durability)
public long delete(DocumentAssignable query, boolean singleDelete, Durability durability) throws MongoDbException
Overridden to call the
deleteAsync(DocumentAssignable, boolean, Durability)
method.
delete
in interface MongoCollection
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.deleteAsync(DocumentAssignable, boolean, Durability)
public long delete(DocumentAssignable query, Durability durability) throws MongoDbException
Overridden to call the
deleteAsync(DocumentAssignable, boolean, Durability)
method with
false as the singleDelete argument.
delete
in interface MongoCollection
query
- Query to locate the documents to be deleted.durability
- The durability for the delete.MongoDbException
- On an error deleting the documents.delete(DocumentAssignable, boolean, Durability)
public void deleteAsync(Callback<Long> results, DocumentAssignable query) throws MongoDbException
Overridden to call the
deleteAsync(Callback, DocumentAssignable, boolean, Durability)
method with false as the singleDelete argument and the
default durability
.
deleteAsync
in interface MongoCollection
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.deleteAsync(Callback, DocumentAssignable, boolean, Durability)
public void deleteAsync(Callback<Long> results, DocumentAssignable query, boolean singleDelete) throws MongoDbException
Overridden to call the
deleteAsync(Callback, DocumentAssignable, boolean, Durability)
method with the default durability
.
deleteAsync
in interface MongoCollection
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.MongoCollection.deleteAsync(Callback, DocumentAssignable)
public abstract void deleteAsync(Callback<Long> results, DocumentAssignable query, boolean singleDelete, Durability durability) throws MongoDbException
This is the canonical delete
method that implementations
must override.
deleteAsync
in interface MongoCollection
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.MongoCollection.deleteAsync(Callback, DocumentAssignable, boolean,
Durability)
public void deleteAsync(Callback<Long> results, DocumentAssignable query, Durability durability) throws MongoDbException
Overridden to call the
deleteAsync(Callback, DocumentAssignable, boolean, Durability)
method with false as the singleDelete argument.
deleteAsync
in interface MongoCollection
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.MongoCollection.deleteAsync(Callback, DocumentAssignable, boolean)
public Future<Long> deleteAsync(DocumentAssignable query) throws MongoDbException
Overridden to call the
deleteAsync(Callback, DocumentAssignable, boolean, Durability)
method with false as the singleDelete argument and the
default durability
.
deleteAsync
in interface MongoCollection
query
- Query to locate the documents to be deleted.MongoDbException
- On an error deleting the documents.MongoCollection.deleteAsync(Callback, DocumentAssignable)
public Future<Long> deleteAsync(DocumentAssignable query, boolean singleDelete) throws MongoDbException
Overridden to call the
deleteAsync(Callback, DocumentAssignable, boolean, Durability)
method with the default durability
.
deleteAsync
in interface MongoCollection
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.MongoCollection.deleteAsync(Callback, DocumentAssignable)
public Future<Long> deleteAsync(DocumentAssignable query, boolean singleDelete, Durability durability) throws MongoDbException
Overridden to call the deleteAsync(Callback, DocumentAssignable)
method.
deleteAsync
in interface MongoCollection
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.MongoCollection.deleteAsync(Callback, DocumentAssignable)
public Future<Long> deleteAsync(DocumentAssignable query, Durability durability) throws MongoDbException
Overridden to call the deleteAsync(Callback, DocumentAssignable)
method with false as the singleDelete argument.
deleteAsync
in interface MongoCollection
query
- Query to locate the documents to be deleted.durability
- The durability for the delete.MongoDbException
- On an error deleting the documents.MongoCollection.deleteAsync(Callback, DocumentAssignable)
public ArrayElement distinct(Distinct command) throws MongoDbException
Overridden to call the distinctAsync(Distinct)
.
distinct
in interface MongoCollection
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.public ArrayElement distinct(Distinct.Builder command) throws MongoDbException
Overridden to call the distinct(Distinct)
.
distinct
in interface MongoCollection
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.public abstract void distinctAsync(Callback<ArrayElement> results, Distinct command) throws MongoDbException
This is the canonical disitnct
method that implementations
must override.
distinctAsync
in interface MongoCollection
results
- Callback for the distinct results returned.command
- The details of the distinct request.MongoDbException
- On an error finding the documents.public void distinctAsync(Callback<ArrayElement> results, Distinct.Builder command) throws MongoDbException
Overridden to call the distinctAsync(Callback, Distinct)
.
distinctAsync
in interface MongoCollection
results
- Callback for the distinct results returned.command
- The details of the distinct request.MongoDbException
- On an error finding the documents.public Future<ArrayElement> distinctAsync(Distinct command) throws MongoDbException
Overridden to call the distinctAsync(Callback, Distinct)
.
distinctAsync
in interface MongoCollection
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.public Future<ArrayElement> distinctAsync(Distinct.Builder command) throws MongoDbException
Overridden to call the distinctAsync(Distinct)
.
distinctAsync
in interface MongoCollection
command
- The details of the distinct request.MongoDbException
- On an error finding the documents.public 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") ); ...
To generate the name of the index and then drop it.
dropIndex
in interface MongoCollection
keys
- The keys for the index to be dropped.MongoDbException
- On an error deleting the indexes.public abstract boolean dropIndex(String name) throws MongoDbException
This is the canonical dropIndex
method that implementations
must override.
dropIndex
in interface MongoCollection
name
- The name of the index.MongoDbException
- On an error deleting the indexes.public Document explain(DocumentAssignable query) throws MongoDbException
Overridden to call the explain(Find)
method.
explain
in interface MongoCollection
query
- The query document.MongoDbException
- On an error finding the documents.explain(Find)
public Document explain(Find query) throws MongoDbException
This is equivalent to calling explainAsync(...).get()
Overridden to call the explainAsync(Find)
method.
explain
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the documents.explainAsync(Find)
public Document explain(Find.Builder query) throws MongoDbException
This is equivalent to calling explainAsync(...).get()
Overridden to call the explain(Find)
method.
explain
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the documents.public abstract void explainAsync(Callback<Document> results, Find query) throws MongoDbException
This is the canonical count
method that implementations must
override.
explainAsync
in interface MongoCollection
results
- Callback that will be notified of the results of the explain.query
- The query details.MongoDbException
- On an error finding the documents.public void explainAsync(Callback<Document> results, Find.Builder query) throws MongoDbException
Overridden to call the explainAsync(Callback,Find)
method.
explainAsync
in interface MongoCollection
results
- Callback that will be notified of the results of the explain.query
- The query details.MongoDbException
- On an error finding the documents.public Future<Document> explainAsync(Find query) throws MongoDbException
Overridden to call the explainAsync(Callback,Find)
method.
explainAsync
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the documents.explainAsync(Callback,Find)
public Future<Document> explainAsync(Find.Builder query) throws MongoDbException
Overridden to call the explainAsync(Find)
method.
explainAsync
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the documents.public MongoIterator<Document> find(DocumentAssignable query) throws MongoDbException
This is equivalent to calling findAsync(...).get()
Overridden to call the findAsync(DocumentAssignable)
method.
find
in interface MongoCollection
query
- The query document.MongoDbException
- On an error finding the documents.findAsync(DocumentAssignable)
public MongoIterator<Document> find(Find query) throws MongoDbException
This is equivalent to calling findAsync(...).get()
Overridden to call the findAsync(Find)
method.
find
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the documents.findAsync(Find)
public MongoIterator<Document> find(Find.Builder query) throws MongoDbException
This is equivalent to calling findAsync(...).get()
Overridden to call the find(Find)
method.
find
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the documents.public Document findAndModify(FindAndModify command) throws MongoDbException
Overridden to call the findAndModifyAsync(FindAndModify)
.
findAndModify
in interface MongoCollection
command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.findAndModifyAsync(FindAndModify)
public Document findAndModify(FindAndModify.Builder command) throws MongoDbException
Overridden to call the findAndModify(FindAndModify)
.
findAndModify
in interface MongoCollection
command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.public abstract void findAndModifyAsync(Callback<Document> results, FindAndModify command) throws MongoDbException
This is the canonical findAndModify
method that
implementations must override.
findAndModifyAsync
in interface MongoCollection
results
- Callback for the the found document.command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.MongoCollection.findAndModifyAsync(Callback, FindAndModify)
public void findAndModifyAsync(Callback<Document> results, FindAndModify.Builder command) throws MongoDbException
Overridden to call the
findAndModifyAsync(Callback,FindAndModify)
.
findAndModifyAsync
in interface MongoCollection
results
- Callback for the the found document.command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.public Future<Document> findAndModifyAsync(FindAndModify command) throws MongoDbException
Overridden to call the
findAndModifyAsync(Callback, FindAndModify)
.
findAndModifyAsync
in interface MongoCollection
command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.findAndModifyAsync(Callback, FindAndModify)
public Future<Document> findAndModifyAsync(FindAndModify.Builder command) throws MongoDbException
Overridden to call the findAndModifyAsync(FindAndModify)
.
findAndModifyAsync
in interface MongoCollection
command
- The details of the find and modify request.MongoDbException
- On an error finding the documents.public void findAsync(Callback<MongoIterator<Document>> results, DocumentAssignable query) throws MongoDbException
Overridden to call the findAsync(Callback, Find)
.
findAsync
in interface MongoCollection
results
- Callback that will be notified of the results of the query.query
- The query document.MongoDbException
- On an error finding the documents.findAsync(Callback, DocumentAssignable)
public abstract void findAsync(Callback<MongoIterator<Document>> results, Find query) throws MongoDbException
This is the canonical find
method that implementations must
override.
findAsync
in interface MongoCollection
results
- Callback that will be notified of the results of the query.query
- The query details.MongoDbException
- On an error finding the documents.MongoCollection.findAsync(Callback, Find)
public void findAsync(Callback<MongoIterator<Document>> results, Find.Builder query) throws MongoDbException
Overridden to call the findAsync(Callback,Find)
method.
findAsync
in interface MongoCollection
results
- Callback that will be notified of the results of the query.query
- The query details.MongoDbException
- On an error finding the documents.public Future<MongoIterator<Document>> findAsync(DocumentAssignable query) throws MongoDbException
Overridden to call the findAsync(Callback, DocumentAssignable)
.
findAsync
in interface MongoCollection
query
- The query document.MongoDbException
- On an error finding the documents.findAsync(Callback, DocumentAssignable)
public Future<MongoIterator<Document>> findAsync(Find query) throws MongoDbException
Overridden to call the findAsync(Callback, Find)
.
findAsync
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the documents.findAsync(Callback, Find)
public Future<MongoIterator<Document>> findAsync(Find.Builder query) throws MongoDbException
Overridden to call the findAsync(Find)
method.
findAsync
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the documents.public Document findOne(DocumentAssignable query) throws MongoDbException
Overridden to call the findOneAsync(DocumentAssignable)
.
findOne
in interface MongoCollection
query
- The query document.MongoDbException
- On an error finding the document.findOneAsync(DocumentAssignable)
public Document findOne(Find query) throws MongoDbException
Overridden to call the findOneAsync(Callback, Find)
.
findOne
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the document.findOneAsync(Callback, Find)
public 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.
Overridden to call the findOne(Find)
method.
findOne
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the document.public void findOneAsync(Callback<Document> results, DocumentAssignable query) throws MongoDbException
Overridden to call the findOneAsync(Callback, Find)
.
findOneAsync
in interface MongoCollection
results
- Callback that will be notified of the results of the query.query
- The query document.MongoDbException
- On an error finding the document.findOneAsync(Callback, Find)
public abstract 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.
This is the canonical findOne
method that implementations
must override.
findOneAsync
in interface MongoCollection
results
- Callback that will be notified of the results of the query.query
- The query details.MongoDbException
- On an error finding the document.MongoCollection.findOneAsync(Callback, Find)
public 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.
Overridden to call the findOneAsync(Callback, Find)
method.
findOneAsync
in interface MongoCollection
results
- Callback that will be notified of the results of the query.query
- The query details.MongoDbException
- On an error finding the document.public Future<Document> findOneAsync(DocumentAssignable query) throws MongoDbException
Overridden to call the
findOneAsync(Callback, DocumentAssignable)
.
findOneAsync
in interface MongoCollection
query
- The query document.MongoDbException
- On an error finding the document.findOneAsync(Callback, DocumentAssignable)
public 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.
Overridden to call the findOneAsync(Callback, Find)
.
findOneAsync
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the document.findOneAsync(Callback, Find)
public 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.
Overridden to call the findOneAsync(Find)
method.
findOneAsync
in interface MongoCollection
query
- The query details.MongoDbException
- On an error finding the document.public String getDatabaseName()
getDatabaseName
in interface MongoCollection
public Durability getDurability()
MongoCollection
instance.
Defaults to the Durability
from the parent MongoDatabase
instance.
getDurability
in interface MongoCollection
MongoDatabase.getDurability()
public String getName()
getName
in interface MongoCollection
public ReadPreference getReadPreference()
MongoCollection
instance.
Defaults to ReadPreference
from the parent MongoDatabase
instance.
getReadPreference
in interface MongoCollection
MongoDatabase.getReadPreference()
public ArrayElement groupBy(GroupBy command) throws MongoDbException
Overridden to call the groupByAsync(GroupBy)
.
groupBy
in interface MongoCollection
command
- The details of the group request.MongoDbException
- On an error finding the documents.public ArrayElement groupBy(GroupBy.Builder command) throws MongoDbException
Overridden to call the groupBy(GroupBy)
.
groupBy
in interface MongoCollection
command
- The details of the group request.MongoDbException
- On an error finding the documents.public abstract void groupByAsync(Callback<ArrayElement> results, GroupBy command) throws MongoDbException
This is the canonical groupBy
method that implementations
must override.
groupByAsync
in interface MongoCollection
results
- Callback for the group results returned.command
- The details of the group request.MongoDbException
- On an error finding the documents.public void groupByAsync(Callback<ArrayElement> results, GroupBy.Builder command) throws MongoDbException
Overridden to call the groupByAsync(Callback,GroupBy)
.
groupByAsync
in interface MongoCollection
results
- Callback for the group results returned.command
- The details of the group request.MongoDbException
- On an error finding the documents.public Future<ArrayElement> groupByAsync(GroupBy command) throws MongoDbException
Overridden to call the groupByAsync(Callback, GroupBy)
.
groupByAsync
in interface MongoCollection
command
- The details of the group request.MongoDbException
- On an error finding the documents.public Future<ArrayElement> groupByAsync(GroupBy.Builder command) throws MongoDbException
Overridden to call the groupByAsync(GroupBy)
.
groupByAsync
in interface MongoCollection
command
- The details of the group request.MongoDbException
- On an error finding the documents.public int insert(boolean continueOnError, DocumentAssignable... documents) throws MongoDbException
This is equivalent to calling
insertAsync(...).get()
Overridden to call the
insert(boolean, Durability, DocumentAssignable...)
method with
the default durability
.
insert
in interface MongoCollection
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.insert(boolean, Durability, DocumentAssignable[])
public int insert(boolean continueOnError, Durability durability, DocumentAssignable... documents) throws MongoDbException
This is equivalent to calling
insertAsync(...).get()
Overridden to call the
insertAsync(boolean, Durability, DocumentAssignable...)
method.
insert
in interface MongoCollection
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.insertAsync(boolean, Durability, DocumentAssignable[])
public int insert(DocumentAssignable... documents) throws MongoDbException
This is equivalent to calling
insertAsync(...).get()
Overridden to call the
insert(boolean, Durability, DocumentAssignable...)
method with
continueOnError set to false and the default durability
.
insert
in interface MongoCollection
documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.MongoCollection.insertAsync(boolean, Durability,
DocumentAssignable[])
public int insert(Durability durability, DocumentAssignable... documents) throws MongoDbException
This is equivalent to calling
insertAsync(...).get()
Overridden to call the
insert(boolean, Durability, DocumentAssignable...)
method with
continueOnError set to false.
insert
in interface MongoCollection
durability
- The durability for the insert.documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.insert(boolean, Durability, DocumentAssignable[])
public Future<Integer> insertAsync(boolean continueOnError, DocumentAssignable... documents) throws MongoDbException
Overridden to call the
insertAsync(Callback, boolean, Durability, DocumentAssignable...)
method with the default durability
.
insertAsync
in interface MongoCollection
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.MongoCollection.insertAsync(Callback, boolean, Durability,
DocumentAssignable[])
public Future<Integer> insertAsync(boolean continueOnError, Durability durability, DocumentAssignable... documents) throws MongoDbException
Overridden to call the
insertAsync(Callback, boolean, Durability, DocumentAssignable...)
method with continueOnError set to false and the
default durability
.
insertAsync
in interface MongoCollection
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.MongoCollection.insertAsync(Callback, boolean, Durability,
DocumentAssignable[])
public void insertAsync(Callback<Integer> results, boolean continueOnError, DocumentAssignable... documents) throws MongoDbException
Overridden to call the
insertAsync(Callback, boolean, Durability, DocumentAssignable...)
method the default durability
.
insertAsync
in interface MongoCollection
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.MongoCollection.insertAsync(Callback, boolean, Durability,
DocumentAssignable[])
public abstract void insertAsync(Callback<Integer> results, boolean continueOnError, Durability durability, DocumentAssignable... documents) throws MongoDbException
This is the canonical insert
method that implementations
must override.
insertAsync
in interface MongoCollection
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.MongoCollection.insertAsync(Callback, boolean, Durability,
DocumentAssignable[])
public void insertAsync(Callback<Integer> results, DocumentAssignable... documents) throws MongoDbException
Overridden to call the
insertAsync(Callback, boolean, Durability, DocumentAssignable...)
method with continueOnError set to false and the
default durability
.
insertAsync
in interface MongoCollection
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.MongoCollection.insertAsync(Callback, boolean, Durability,
DocumentAssignable[])
public void insertAsync(Callback<Integer> results, Durability durability, DocumentAssignable... documents) throws MongoDbException
Overridden to call the
insertAsync(Callback, boolean, Durability, DocumentAssignable...)
method with continueOnError set to false.
insertAsync
in interface MongoCollection
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.MongoCollection.insertAsync(Callback, boolean, Durability,
DocumentAssignable[])
public Future<Integer> insertAsync(DocumentAssignable... documents) throws MongoDbException
Overridden to call the
insertAsync(Callback, boolean, Durability, DocumentAssignable...)
method with continueOnError set to false and the
default durability
.
insertAsync
in interface MongoCollection
documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.MongoCollection.insertAsync(Callback, boolean, Durability,
DocumentAssignable[])
public Future<Integer> insertAsync(Durability durability, DocumentAssignable... documents) throws MongoDbException
Overridden to call the
insertAsync(Callback, boolean, Durability, DocumentAssignable...)
method with continueOnError set to false.
insertAsync
in interface MongoCollection
durability
- The durability for the insert.documents
- The documents to add to the collection.-1
.MongoDbException
- On an error inserting the documents.MongoCollection.insertAsync(Callback, boolean, Durability,
DocumentAssignable[])
public List<Document> mapReduce(MapReduce command) throws MongoDbException
Overridden to call the mapReduceAsync(MapReduce)
.
mapReduce
in interface MongoCollection
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.mapReduceAsync(MapReduce)
public List<Document> mapReduce(MapReduce.Builder command) throws MongoDbException
Overridden to call the mapReduce(MapReduce)
.
mapReduce
in interface MongoCollection
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.public abstract void mapReduceAsync(Callback<List<Document>> results, MapReduce command) throws MongoDbException
This is the canonical mapReduce
method that implementations
must override.
mapReduceAsync
in interface MongoCollection
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.MongoCollection.mapReduceAsync(Callback, MapReduce)
public void mapReduceAsync(Callback<List<Document>> results, MapReduce.Builder command) throws MongoDbException
Overridden to call the mapReduceAsync(Callback,MapReduce)
.
mapReduceAsync
in interface MongoCollection
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.public Future<List<Document>> mapReduceAsync(MapReduce command) throws MongoDbException
Overridden to call the mapReduceAsync(Callback, MapReduce)
.
mapReduceAsync
in interface MongoCollection
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.mapReduceAsync(Callback, MapReduce)
public Future<List<Document>> mapReduceAsync(MapReduce.Builder command) throws MongoDbException
Overridden to call the mapReduceAsync(MapReduce)
.
mapReduceAsync
in interface MongoCollection
command
- The details of the map/reduce request.MongoDbException
- On an error finding the documents.public 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)
.
Overridden to call the save(DocumentAssignable, Durability)
using the default durability
.
save
in interface MongoCollection
document
- The document to save to the collection.MongoDbException
- On an error saving the documents.public 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)
.
Overridden to call the saveAsync(DocumentAssignable, Durability)
.
save
in interface MongoCollection
document
- The document to save to the collection.durability
- The durability for the save.MongoDbException
- On an error saving the documents.public 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)
.
Overridden to call the
saveAsync(Callback, DocumentAssignable, Durability)
using the
default durability
.
saveAsync
in interface MongoCollection
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.public abstract 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)
.
This is the canonical save
method that implementations must
override.
saveAsync
in interface MongoCollection
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.public 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)
.
Overridden to call the
saveAsync(Callback, DocumentAssignable, Durability)
using the
default durability
.
saveAsync
in interface MongoCollection
document
- The document to save to the collection.MongoDbException
- On an error saving the documents.public 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)
.
Overridden to call the
saveAsync(Callback, DocumentAssignable, Durability)
.
saveAsync
in interface MongoCollection
document
- The document to save to the collection.durability
- The durability for the save.MongoDbException
- On an error saving the documents.public void setDurability(Durability durability)
MongoCollection
instance.
Defaults to the Durability
from the parent MongoDatabase
instance if set to null
.
setDurability
in interface MongoCollection
durability
- The durability for write operations on the server.MongoDatabase.getDurability()
public void setReadPreference(ReadPreference readPreference)
MongoCollection
instance.
Defaults to the ReadPreference
from the parent
MongoDatabase
instance if set to null
.
setReadPreference
in interface MongoCollection
readPreference
- The read preference for a query.MongoDatabase.getReadPreference()
@Deprecated public MongoCursorControl streamingFind(Callback<Document> results, DocumentAssignable query) throws MongoDbException
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.
Overridden to call the streamingFind(Callback, Find)
.
streamingFind
in interface MongoCollection
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.streamingFind(Callback, Find)
@Deprecated public MongoCursorControl streamingFind(Callback<Document> results, Find query) throws MongoDbException
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.
Overridden to call the streamingFind(StreamCallback, Find)
.
streamingFind
in interface MongoCollection
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.streamingFind(StreamCallback, Find)
public 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.
Overridden to call the streamingFind(StreamCallback, Find)
.
streamingFind
in interface MongoCollection
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.streamingFind(StreamCallback, Find)
public abstract 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.
This is the canonical streamingFind
method that
implementations must override.
streamingFind
in interface MongoCollection
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.public 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.
Overridden to call the streamingFind(StreamCallback, Find)
method.
streamingFind
in interface MongoCollection
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.public List<TextResult> textSearch(Text command) throws MongoDbException
text
command on the server.
Overridden to call the textSearchAsync(Text)
.
textSearch
in interface MongoCollection
command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.textSearchAsync(Text)
public List<TextResult> textSearch(Text.Builder command) throws MongoDbException
text
command on the server.
Overridden to call the textSearch(Text)
.
textSearch
in interface MongoCollection
command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.public abstract void textSearchAsync(Callback<List<TextResult>> results, Text command) throws MongoDbException
text
command on the server.
This is the canonical textSearch
method that implementations
must override.
textSearchAsync
in interface MongoCollection
results
- Callback for the text
results returned.command
- The details of the text
request.MongoDbException
- On an error executing the text
command.MongoCollection.textSearchAsync(Callback, Text)
public void textSearchAsync(Callback<List<TextResult>> results, Text.Builder command) throws MongoDbException
text
command on the server.
Overridden to call the textSearchAsync(Callback, Text)
.
textSearchAsync
in interface MongoCollection
results
- Callback for the text
results returned.command
- The details of the text
request.MongoDbException
- On an error executing the text
command.public Future<List<TextResult>> textSearchAsync(Text command) throws MongoDbException
text
command on the server.
Overridden to call the textSearchAsync(Callback, Text)
.
textSearchAsync
in interface MongoCollection
command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.textSearchAsync(Callback, Text)
public Future<List<TextResult>> textSearchAsync(Text.Builder command) throws MongoDbException
text
command on the server.
Overridden to call the textSearchAsync(Text)
.
textSearchAsync
in interface MongoCollection
command
- The details of the text
request.text
results returned.MongoDbException
- On an error executing the text
command.public long update(DocumentAssignable query, DocumentAssignable update) throws MongoDbException
Overridden to call the
update(DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
method with multiUpdate set to true, upsert set to false, and using the
default durability
.
update
in interface MongoCollection
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.update(DocumentAssignable, DocumentAssignable, boolean, boolean,
Durability)
public long update(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert) throws MongoDbException
Overridden to call the
update(DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
method with the default durability
.
update
in interface MongoCollection
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.update(DocumentAssignable, DocumentAssignable, boolean, boolean,
Durability)
public long update(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert, Durability durability) throws MongoDbException
Overridden to call the
updateAsync(DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
method.
update
in interface MongoCollection
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.updateAsync(DocumentAssignable, DocumentAssignable, boolean,
boolean, Durability)
public long update(DocumentAssignable query, DocumentAssignable update, Durability durability) throws MongoDbException
Overridden to call the
update(DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
method with multiUpdate set to true, and upsert set to false.
update
in interface MongoCollection
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.update(DocumentAssignable, DocumentAssignable, boolean, boolean,
Durability)
public void updateAsync(Callback<Long> results, DocumentAssignable query, DocumentAssignable update) throws MongoDbException
Overridden to call the
updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
with multiUpdate set to true, upsert set to false, and using the
default durability
.
updateAsync
in interface MongoCollection
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.updateAsync(Callback, DocumentAssignable, DocumentAssignable,
boolean, boolean, Durability)
public void updateAsync(Callback<Long> results, DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert) throws MongoDbException
Overridden to call the
updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
using the default durability
.
updateAsync
in interface MongoCollection
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.updateAsync(Callback, DocumentAssignable, DocumentAssignable,
boolean, boolean, Durability)
public abstract void updateAsync(Callback<Long> results, DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert, Durability durability) throws MongoDbException
This is the canonical update
method that implementations
must override.
updateAsync
in interface MongoCollection
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.MongoCollection.updateAsync(Callback, DocumentAssignable,
DocumentAssignable, boolean, boolean, Durability)
public void updateAsync(Callback<Long> results, DocumentAssignable query, DocumentAssignable update, Durability durability) throws MongoDbException
Overridden to call the
updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
with multiUpdate set to true, and upsert set to false.
updateAsync
in interface MongoCollection
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.updateAsync(Callback, DocumentAssignable, DocumentAssignable,
boolean, boolean, Durability)
public Future<Long> updateAsync(DocumentAssignable query, DocumentAssignable update) throws MongoDbException
Overridden to call the
updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
with multiUpdate set to true, upsert set to false, and using the
default durability
.
updateAsync
in interface MongoCollection
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.updateAsync(Callback, DocumentAssignable, DocumentAssignable,
boolean, boolean, Durability)
public Future<Long> updateAsync(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert) throws MongoDbException
Overridden to call the
updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
using the default durability
.
updateAsync
in interface MongoCollection
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.updateAsync(Callback, DocumentAssignable, DocumentAssignable,
boolean, boolean, Durability)
public Future<Long> updateAsync(DocumentAssignable query, DocumentAssignable update, boolean multiUpdate, boolean upsert, Durability durability) throws MongoDbException
Overridden to call the
updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
method.
updateAsync
in interface MongoCollection
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.updateAsync(Callback, DocumentAssignable, DocumentAssignable,
boolean, boolean, Durability)
public Future<Long> updateAsync(DocumentAssignable query, DocumentAssignable update, Durability durability) throws MongoDbException
Overridden to call the
updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
with multiUpdate set to true, and upsert set to false.
updateAsync
in interface MongoCollection
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.updateAsync(Callback, DocumentAssignable, DocumentAssignable,
boolean, boolean, Durability)
protected GetLastError asGetLastError(Durability durability)
Durability
into a GetLastError
command.durability
- The Durability
to convert.GetLastError
command.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.