Class CoreSyncImpl<DocumentT>
- java.lang.Object
-
- com.mongodb.stitch.core.services.mongodb.remote.sync.internal.CoreSyncImpl<DocumentT>
-
-
Constructor Summary
Constructors Constructor Description CoreSyncImpl(MongoNamespace namespace, Class<DocumentT> documentClass, DataSynchronizer dataSynchronizer, CoreStitchServiceClient service, SyncOperations<DocumentT> syncOperations)
-
Method Summary
Modifier and Type Method Description CoreSyncAggregateIterable<DocumentT>
aggregate(List<? extends Bson> pipeline)
Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.<ResultT> CoreSyncAggregateIterable<ResultT>
aggregate(List<? extends Bson> pipeline, Class<ResultT> resultClass)
Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.void
configure(SyncConfiguration syncConfig)
Set the conflict resolver and and change event listener on this collection.long
count()
Counts the number of documents in the collection that have been synchronized with the remote.long
count(Bson filter)
Counts the number of documents in the collection that have been synchronized with the remote according to the given options.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.SyncDeleteResult
deleteMany(Bson filter)
Removes all documents from the collection that have been synchronized with the remote that match the given query filter.SyncDeleteResult
deleteOne(Bson filter)
Removes at most one document from the collection that has been synchronized with the remote that matches the given filter.void
desyncMany(BsonValue... ids)
Stops synchronizing the given document _ids.void
desyncOne(BsonValue id)
Stops synchronizing the given document _id.CoreSyncFindIterable<DocumentT>
find()
Finds all documents in the collection that have been synchronized with the remote.<ResultT> CoreSyncFindIterable<ResultT>
find(Class<ResultT> resultClass)
Finds all documents in the collection that have been synchronized with the remote.CoreSyncFindIterable<DocumentT>
find(Bson filter)
Finds all documents in the collection that have been synchronized with the remote.<ResultT> CoreSyncFindIterable<ResultT>
find(Bson filter, Class<ResultT> resultClass)
Finds all documents in the collection.DocumentT
findOne()
Finds a document in the collection.<ResultT> ResultT
findOne(Class<ResultT> resultClass)
Finds a document in the collection.DocumentT
findOne(Bson filter)
Finds a document in the collection.DocumentT
findOne(Bson filter, RemoteFindOptions options)
Finds a document in the collection.<ResultT> ResultT
findOne(Bson filter, RemoteFindOptions options, Class<ResultT> resultClass)
Finds a document in the collection.<ResultT> ResultT
findOne(Bson filter, Class<ResultT> resultClass)
Finds a document in the collection.Set<BsonValue>
getPausedDocumentIds()
Return the set of synchronized document _ids in a namespace that have been paused due to an irrecoverable error.Set<BsonValue>
getSyncedIds()
Returns the set of synchronized document ids in a namespace.SyncInsertManyResult
insertMany(List<DocumentT> documents)
Inserts one or more documents.SyncInsertOneResult
insertOne(DocumentT document)
Inserts the provided document.boolean
resumeSyncForDocument(BsonValue documentId)
A document that is paused no longer has remote updates applied to it.void
syncMany(BsonValue... ids)
Requests that the given document _ids be synchronized.void
syncOne(BsonValue id)
Requests that the given document _id be synchronized.SyncUpdateResult
updateMany(Bson filter, Bson update)
Update all documents in the collection that have been synchronized with the remote according to the specified arguments.SyncUpdateResult
updateMany(Bson filter, Bson update, SyncUpdateOptions updateOptions)
Update all documents in the collection that have been synchronized with the remote according to the specified arguments.SyncUpdateResult
updateOne(Bson filter, Bson update)
Update a single document in the collection that have been synchronized with the remote according to the specified arguments.SyncUpdateResult
updateOne(Bson filter, Bson update, SyncUpdateOptions updateOptions)
Update a single document in the collection that has been synchronized with the remote according to the specified arguments.void
updateSyncFrequency(SyncFrequency syncFrequency)
Set the SyncFrequency on this collection.
-
-
-
Constructor Detail
-
CoreSyncImpl
public CoreSyncImpl(MongoNamespace namespace, Class<DocumentT> documentClass, DataSynchronizer dataSynchronizer, CoreStitchServiceClient service, SyncOperations<DocumentT> syncOperations)
-
-
Method Detail
-
configure
public void configure(@Nonnull SyncConfiguration syncConfig)
Description copied from interface:CoreSync
Set the conflict resolver and and change event listener on this collection.
-
updateSyncFrequency
public void updateSyncFrequency(@Nonnull SyncFrequency syncFrequency)
Set the SyncFrequency on this collection.- Specified by:
updateSyncFrequency
in interfaceCoreSync<DocumentT>
- Parameters:
syncFrequency
- the SyncFrequency that contains relevant options
-
syncOne
public void syncOne(BsonValue id)
Description copied from interface:CoreSync
Requests that the given document _id be synchronized.
-
syncMany
public void syncMany(BsonValue... ids)
Description copied from interface:CoreSync
Requests that the given document _ids be synchronized.
-
desyncOne
public void desyncOne(BsonValue id)
Description copied from interface:CoreSync
Stops synchronizing the given document _id. Any uncommitted writes will be lost.
-
desyncMany
public void desyncMany(BsonValue... ids)
Description copied from interface:CoreSync
Stops synchronizing the given document _ids. Any uncommitted writes will be lost.- Specified by:
desyncMany
in interfaceCoreSync<DocumentT>
- Parameters:
ids
- the _ids of the documents to desynchronize.
-
getSyncedIds
public Set<BsonValue> getSyncedIds()
Description copied from interface:CoreSync
Returns the set of synchronized document ids in a namespace.- Specified by:
getSyncedIds
in interfaceCoreSync<DocumentT>
- Returns:
- the set of synchronized document ids in a namespace.
-
getPausedDocumentIds
public Set<BsonValue> getPausedDocumentIds()
Description copied from interface:CoreSync
Return the set of synchronized document _ids in a namespace that have been paused due to an irrecoverable error.- Specified by:
getPausedDocumentIds
in interfaceCoreSync<DocumentT>
- Returns:
- the set of paused document _ids in a namespace
-
resumeSyncForDocument
public boolean resumeSyncForDocument(BsonValue documentId)
Description copied from interface:CoreSync
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 interfaceCoreSync<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 long count()
Description copied from interface:CoreSync
Counts the number of documents in the collection that have been synchronized with the remote.
-
count
public long count(Bson filter)
Description copied from interface:CoreSync
Counts the number of documents in the collection that have been synchronized with the remote according to the given options.
-
count
public long count(Bson filter, SyncCountOptions options)
Description copied from interface:CoreSync
Counts the number of documents in the collection that have been synchronized with the remote according to the given options.
-
aggregate
public CoreSyncAggregateIterable<DocumentT> aggregate(List<? extends Bson> pipeline)
Description copied from interface:CoreSync
Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.
-
aggregate
public <ResultT> CoreSyncAggregateIterable<ResultT> aggregate(List<? extends Bson> pipeline, Class<ResultT> resultClass)
Description copied from interface:CoreSync
Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.
-
updateOne
public SyncUpdateResult updateOne(Bson filter, Bson update)
Description copied from interface:CoreSync
Update a single document in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.- Specified by:
updateOne
in interfaceCoreSync<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 SyncUpdateResult updateOne(Bson filter, Bson update, SyncUpdateOptions updateOptions)
Description copied from interface:CoreSync
Update a single document in the collection that has been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.- Specified by:
updateOne
in interfaceCoreSync<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 SyncUpdateResult updateMany(Bson filter, Bson update)
Description copied from interface:CoreSync
Update all documents in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.- Specified by:
updateMany
in interfaceCoreSync<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 SyncUpdateResult updateMany(Bson filter, Bson update, SyncUpdateOptions updateOptions)
Description copied from interface:CoreSync
Update all documents in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.- Specified by:
updateMany
in interfaceCoreSync<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
-
insertOne
public SyncInsertOneResult insertOne(DocumentT document)
Description copied from interface:CoreSync
Inserts the provided document. If the document is missing an identifier, the client should generate one. Syncs the newly inserted document against the remote.
-
insertMany
public SyncInsertManyResult insertMany(List<DocumentT> documents)
Description copied from interface:CoreSync
Inserts one or more documents. Syncs the newly inserted documents against the remote.- Specified by:
insertMany
in interfaceCoreSync<DocumentT>
- Parameters:
documents
- the documents to insert- Returns:
- the result of the insert many operation
-
deleteOne
public SyncDeleteResult deleteOne(Bson filter)
Description copied from interface:CoreSync
Removes at most one document from the collection that has been synchronized with the remote that matches the given filter. If no documents match, the collection is not modified.
-
deleteMany
public SyncDeleteResult deleteMany(Bson filter)
Description copied from interface:CoreSync
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 interfaceCoreSync<DocumentT>
- Parameters:
filter
- the query filter to apply the the delete operation- Returns:
- the result of the remove many operation
-
findOne
public DocumentT findOne()
Description copied from interface:CoreSync
Finds a document in the collection.
-
findOne
public DocumentT findOne(Bson filter)
Description copied from interface:CoreSync
Finds a document in the collection.
-
findOne
public DocumentT findOne(Bson filter, RemoteFindOptions options)
Description copied from interface:CoreSync
Finds a document in the collection.
-
findOne
public <ResultT> ResultT findOne(Class<ResultT> resultClass)
Description copied from interface:CoreSync
Finds a document in the collection.
-
findOne
public <ResultT> ResultT findOne(Bson filter, Class<ResultT> resultClass)
Description copied from interface:CoreSync
Finds a document in the collection.
-
findOne
public <ResultT> ResultT findOne(Bson filter, RemoteFindOptions options, Class<ResultT> resultClass)
Description copied from interface:CoreSync
Finds a document in the collection.
-
find
public CoreSyncFindIterable<DocumentT> find()
Description copied from interface:CoreSync
Finds all documents in the collection that have been synchronized with the remote.
-
find
public CoreSyncFindIterable<DocumentT> find(Bson filter)
Description copied from interface:CoreSync
Finds all documents in the collection that have been synchronized with the remote.
-
find
public <ResultT> CoreSyncFindIterable<ResultT> find(Class<ResultT> resultClass)
Description copied from interface:CoreSync
Finds all documents in the collection that have been synchronized with the remote.
-
find
public <ResultT> CoreSyncFindIterable<ResultT> find(Bson filter, Class<ResultT> resultClass)
Finds all documents in the collection.
-
-