Class SyncImpl<DocumentT>
- java.lang.Object
-
- com.mongodb.stitch.android.services.mongodb.remote.internal.SyncImpl<DocumentT>
-
-
Method Summary
Modifier and Type Method Description SyncAggregateIterable<DocumentT>
aggregate(List<? extends Bson> pipeline)
Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.<ResultT> SyncAggregateIterable<ResultT>
aggregate(List<? extends Bson> pipeline, Class<ResultT> resultClass)
Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.Task<Void>
configure(ConflictHandler<DocumentT> conflictHandler, ChangeEventListener<DocumentT> changeEventListener, ExceptionListener exceptionListener)
Set the conflict handler and and change event listener on this collection.Task<Void>
configure(ConflictHandler<DocumentT> conflictHandler, ChangeEventListener<DocumentT> changeEventListener, ExceptionListener exceptionListener, SyncFrequency syncFrequency)
Set the conflict handler and and change event listener on this collection.Task<Void>
configure(SyncConfiguration syncConfiguration)
Set the conflict handler and and change event listener on this collection.Task<Long>
count()
Counts the number of documents in the collection that have been synchronized with the remote.Task<Long>
count(Bson filter)
Counts the number of documents in the collection that have been synchronized with the remote according to the given options.Task<Long>
count(Bson filter, SyncCountOptions options)
Counts the number of documents in the collection that have been synchronized with the remote according to the given options.Task<SyncDeleteResult>
deleteMany(Bson filter)
Removes all documents from the collection that have been synchronized with the remote that match the given query filter.Task<SyncDeleteResult>
deleteOne(Bson filter)
Removes at most one document that has been synchronized with the remote from the collection that matches the given filter.Task<Void>
desyncMany(BsonValue... ids)
Stops synchronizing the given document _ids.Task<Void>
desyncOne(BsonValue id)
Stops synchronizing the given document _id.SyncFindIterable<DocumentT>
find()
Finds all documents in the collection that have been synchronized with the remote.<ResultT> SyncFindIterable<ResultT>
find(Class<ResultT> resultClass)
Finds all documents in the collection that have been synchronized with the remote.SyncFindIterable<DocumentT>
find(Bson filter)
Finds all documents in the collection that have been synchronized with the remote.<ResultT> SyncFindIterable<ResultT>
find(Bson filter, Class<ResultT> resultClass)
Finds all documents in the collection that have been synchronized with the remote.Task<Set<BsonValue>>
getPausedDocumentIds()
Return the set of synchronized document _ids in a namespace that have been paused due to an irrecoverable error.Task<Set<BsonValue>>
getSyncedIds()
Returns the set of synchronized document ids in a namespace.Task<SyncInsertManyResult>
insertMany(List<DocumentT> documents)
Inserts one or more documents.Task<SyncInsertOneResult>
insertOne(DocumentT document)
Inserts the provided document.Task<Boolean>
resumeSyncForDocument(BsonValue documentId)
A document that is paused no longer has remote updates applied to it.Task<Void>
syncMany(BsonValue... ids)
Requests that the given document _ids be synchronized.Task<Void>
syncOne(BsonValue id)
Requests that the given document _id be synchronized.Task<SyncUpdateResult>
updateMany(Bson filter, Bson update)
Update all documents that have been synchronized with the remote in the collection according to the specified arguments.Task<SyncUpdateResult>
updateMany(Bson filter, Bson update, SyncUpdateOptions updateOptions)
Update all documents that have been synchronized with the remote in the collection according to the specified arguments.Task<SyncUpdateResult>
updateOne(Bson filter, Bson update)
Update a single document that has been synchronized with the remote in the collection according to the specified arguments.Task<SyncUpdateResult>
updateOne(Bson filter, Bson update, SyncUpdateOptions updateOptions)
Update a single document that has been synchronized with the remote in the collection according to the specified arguments.Task<Void>
updateSyncFrequency(SyncFrequency syncFrequency)
Sets the SyncFrequency on this collection.
-
-
-
Method Detail
-
configure
public Task<Void> configure(@NonNull ConflictHandler<DocumentT> conflictHandler, @Nullable ChangeEventListener<DocumentT> changeEventListener, @Nullable ExceptionListener exceptionListener)
Description copied from interface:Sync
Set the conflict handler and and change event listener on this collection. This will start a background sync thread, and should be called before any CRUD operations are attempted.- Specified by:
configure
in interfaceSync<DocumentT>
- Parameters:
conflictHandler
- the conflict resolver to invoke when a conflict happens between local and remote events.changeEventListener
- the event listener to invoke when a change event happens for the document.exceptionListener
- the error listener to invoke when an irrecoverable error occurs- Returns:
- A Task that completes when Mobile Sync is configured, and the background sync thread has started.
-
configure
public Task<Void> configure(@NonNull ConflictHandler<DocumentT> conflictHandler, @Nullable ChangeEventListener<DocumentT> changeEventListener, @Nullable ExceptionListener exceptionListener, @Nullable SyncFrequency syncFrequency)
Description copied from interface:Sync
Set the conflict handler and and change event listener on this collection. This will start a background sync thread, and should be called before any CRUD operations are attempted.- Specified by:
configure
in interfaceSync<DocumentT>
- Parameters:
conflictHandler
- the conflict resolver to invoke when a conflict happens between local and remote events.changeEventListener
- the event listener to invoke when a change event happens for the document.exceptionListener
- the error listener to invoke when an irrecoverable error occurssyncFrequency
- the syncFrequency at which to perform synchronization passes- Returns:
- A Task that completes when Mobile Sync is configured, and the background sync thread has started.
-
configure
public Task<Void> configure(@NonNull SyncConfiguration syncConfiguration)
Description copied from interface:Sync
Set the conflict handler and and change event listener on this collection. This will start a background sync thread, and should be called before any CRUD operations are attempted.
-
updateSyncFrequency
public Task<Void> updateSyncFrequency(@NonNull SyncFrequency syncFrequency)
Sets the SyncFrequency on this collection.- Specified by:
updateSyncFrequency
in interfaceSync<DocumentT>
- Parameters:
syncFrequency
- the SyncFrequency that contains all the desired options- Returns:
- A Task that completes when the SyncFrequency has been updated
-
syncOne
public Task<Void> syncOne(BsonValue id)
Description copied from interface:Sync
Requests that the given document _id be synchronized.
-
syncMany
public Task<Void> syncMany(BsonValue... ids)
Description copied from interface:Sync
Requests that the given document _ids be synchronized.
-
desyncOne
public Task<Void> desyncOne(BsonValue id)
Description copied from interface:Sync
Stops synchronizing the given document _id. Any uncommitted writes will be lost.- Specified by:
desyncOne
in interfaceSync<DocumentT>
- Parameters:
id
- the _id of the document to desynchronize.- Returns:
- a Task that completes when the specified document ID is no longer configured as synced. The document will be removed from the local collection, but it will not be necessarily deleted from the remote collection.
-
desyncMany
public Task<Void> desyncMany(BsonValue... ids)
Description copied from interface:Sync
Stops synchronizing the given document _ids. Any uncommitted writes will be lost.- Specified by:
desyncMany
in interfaceSync<DocumentT>
- Parameters:
ids
- the _ids of the documents to desynchronize.- Returns:
- a Task that completes when the specified document ID is no longer configured as synced. The documents will be removed from the local collection, but they are not necessarily deleted from the remote collection.
-
getSyncedIds
public Task<Set<BsonValue>> getSyncedIds()
Description copied from interface:Sync
Returns the set of synchronized document ids in a namespace.- Specified by:
getSyncedIds
in interfaceSync<DocumentT>
- Returns:
- the set of synchronized document ids in a namespace.
-
getPausedDocumentIds
public Task<Set<BsonValue>> getPausedDocumentIds()
Description copied from interface:Sync
Return the set of synchronized document _ids in a namespace that have been paused due to an irrecoverable error.- Specified by:
getPausedDocumentIds
in interfaceSync<DocumentT>
- Returns:
- the set of paused document _ids in a namespace
-
resumeSyncForDocument
public Task<Boolean> resumeSyncForDocument(@NonNull BsonValue documentId)
Description copied from interface:Sync
A document that is paused no longer has remote updates applied to it. Any local updates to this document cause it to be resumed. An example of pausing a document is when a conflict is being resolved for that document and the handler throws an exception.- Specified by:
resumeSyncForDocument
in interfaceSync<DocumentT>
- Parameters:
documentId
- the id of the document to resume syncing- Returns:
- true if successfully resumed, false if the document could not be found or there was an error resuming
-
count
public Task<Long> count()
Description copied from interface:Sync
Counts the number of documents in the collection that have been synchronized with the remote.
-
count
public Task<Long> count(Bson filter)
Description copied from interface:Sync
Counts the number of documents in the collection that have been synchronized with the remote according to the given options.
-
count
public Task<Long> count(Bson filter, SyncCountOptions options)
Description copied from interface:Sync
Counts the number of documents in the collection that have been synchronized with the remote according to the given options.
-
aggregate
public SyncAggregateIterable<DocumentT> aggregate(List<? extends Bson> pipeline)
Description copied from interface:Sync
Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.
-
aggregate
public <ResultT> SyncAggregateIterable<ResultT> aggregate(List<? extends Bson> pipeline, Class<ResultT> resultClass)
Description copied from interface:Sync
Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.
-
find
public SyncFindIterable<DocumentT> find()
Description copied from interface:Sync
Finds all documents in the collection that have been synchronized with the remote.
-
find
public SyncFindIterable<DocumentT> find(Bson filter)
Description copied from interface:Sync
Finds all documents in the collection that have been synchronized with the remote.
-
find
public <ResultT> SyncFindIterable<ResultT> find(Class<ResultT> resultClass)
Description copied from interface:Sync
Finds all documents in the collection that have been synchronized with the remote.
-
find
public <ResultT> SyncFindIterable<ResultT> find(Bson filter, Class<ResultT> resultClass)
Description copied from interface:Sync
Finds all documents in the collection that have been synchronized with the remote.
-
insertOne
public Task<SyncInsertOneResult> insertOne(DocumentT document)
Description copied from interface:Sync
Inserts the provided document. If the document is missing an identifier, one will be generated. Begin synchronizating on the document's id.
-
insertMany
public Task<SyncInsertManyResult> insertMany(List<DocumentT> documents)
Description copied from interface:Sync
Inserts one or more documents. If the documents are missing an identifier, they will be generated. Begin synchronizing on the documents' ids.- Specified by:
insertMany
in interfaceSync<DocumentT>
- Parameters:
documents
- the documents to insert- Returns:
- the result of the insert many operation
-
updateOne
public Task<SyncUpdateResult> updateOne(Bson filter, Bson update)
Description copied from interface:Sync
Update a single document that has been synchronized with the remote in the collection according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.- Specified by:
updateOne
in interfaceSync<DocumentT>
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.- Returns:
- the result of the update one operation
-
updateOne
public Task<SyncUpdateResult> updateOne(Bson filter, Bson update, SyncUpdateOptions updateOptions)
Description copied from interface:Sync
Update a single document that has been synchronized with the remote in the collection according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.- Specified by:
updateOne
in interfaceSync<DocumentT>
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions
- the options to apply to the update operation- Returns:
- the result of the update one operation
-
updateMany
public Task<SyncUpdateResult> updateMany(Bson filter, Bson update)
Description copied from interface:Sync
Update all documents that have been synchronized with the remote in the collection according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.- Specified by:
updateMany
in interfaceSync<DocumentT>
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.- Returns:
- the result of the update many operation
-
updateMany
public Task<SyncUpdateResult> updateMany(Bson filter, Bson update, SyncUpdateOptions updateOptions)
Description copied from interface:Sync
Update all documents that have been synchronized with the remote in the collection according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.- Specified by:
updateMany
in interfaceSync<DocumentT>
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions
- the options to apply to the update operation- Returns:
- the result of the update many operation
-
deleteOne
public Task<SyncDeleteResult> deleteOne(Bson filter)
Description copied from interface:Sync
Removes at most one document that has been synchronized with the remote from the collection that matches the given filter. If no documents match, the collection is not modified.
-
deleteMany
public Task<SyncDeleteResult> deleteMany(Bson filter)
Description copied from interface:Sync
Removes all documents from the collection that have been synchronized with the remote that match the given query filter. If no documents match, the collection is not modified.- Specified by:
deleteMany
in interfaceSync<DocumentT>
- Parameters:
filter
- the query filter to apply the the delete operation- Returns:
- the result of the remove many operation
-
-