Class RemoteUpdateResult
- java.lang.Object
-
- com.mongodb.stitch.core.services.mongodb.remote.RemoteUpdateResult
-
- Direct Known Subclasses:
SyncUpdateResult
public class RemoteUpdateResult extends Object
The result of an update operation.
-
-
Example
Document filterDoc = new Document().append("name", "legos"); Document updateDoc = new Document().append("$set", new Document() .append("name", "blocks") .append("price", 20.99) .append("category", "toys") ); final Task<RemoteUpdateResult> updateTask = itemsCollection.updateOne(filterDoc, updateDoc); updateTask.addOnCompleteListener(new OnCompleteListener <RemoteUpdateResult> () { @Override public void onComplete(@NonNull Task <RemoteUpdateResult> task) { if (task.isSuccessful()) { long numMatched = task.getResult().getMatchedCount(); long numModified = task.getResult().getModifiedCount(); Log.d("app", String.format("successfully matched %d and modified %d documents", numMatched, numModified)); } else { Log.e("app", "failed to update document with: ", task.getException()); } } });
-
-
-
Constructor Summary
Constructors Constructor Description RemoteUpdateResult(long matchedCount, long modifiedCount, BsonValue upsertedId)Constructs a result.
-
Method Summary
Modifier and Type Method Description longgetMatchedCount()Returns the number of documents matched by the query.longgetModifiedCount()Returns the number of documents modified.BsonValuegetUpsertedId()If the replace resulted in an inserted document, gets the _id of the inserted document, otherwise null.
-
-
-
Constructor Detail
-
RemoteUpdateResult
public RemoteUpdateResult(long matchedCount, long modifiedCount, BsonValue upsertedId)Constructs a result.- Parameters:
matchedCount- the number of documents matched by the query.modifiedCount- the number of documents modified.upsertedId- the _id of the inserted document if the replace resulted in an inserted document, otherwise null.
-
-