Class UpdateManyModel<T>

java.lang.Object
com.mongodb.client.model.WriteModel<T>
com.mongodb.client.model.UpdateManyModel<T>
Type Parameters:
T - the type of document to update. In practice this doesn't actually apply to updates but is here for consistency with the other write models

public final class UpdateManyModel<T> extends WriteModel<T>
A model describing an update to all documents that matches the query filter. The update to apply must include only update operators.
Since:
3.0
MongoDB documentation
Updates
Update Operators
  • Constructor Summary

    Constructors
    Constructor
    Description
    UpdateManyModel(org.bson.conversions.Bson filter, List<? extends org.bson.conversions.Bson> update)
    Construct a new instance.
    UpdateManyModel(org.bson.conversions.Bson filter, List<? extends org.bson.conversions.Bson> update, UpdateOptions options)
    Construct a new instance.
    UpdateManyModel(org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
    Construct a new instance.
    UpdateManyModel(org.bson.conversions.Bson filter, org.bson.conversions.Bson update, UpdateOptions options)
    Construct a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bson.conversions.Bson
    Gets the query filter.
    Gets the options to apply.
    org.bson.conversions.Bson
    Gets the document specifying the updates to apply to the matching document.
    List<? extends org.bson.conversions.Bson>
    Gets the pipeline specifying the updates to apply to the matching document.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UpdateManyModel

      public UpdateManyModel(org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
      Construct a new instance.
      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.
    • UpdateManyModel

      public UpdateManyModel(org.bson.conversions.Bson filter, org.bson.conversions.Bson update, UpdateOptions options)
      Construct a new instance.
      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.
      options - the options to apply
    • UpdateManyModel

      public UpdateManyModel(org.bson.conversions.Bson filter, List<? extends org.bson.conversions.Bson> update)
      Construct a new instance.
      Parameters:
      filter - a document describing the query filter, which may not be null.
      update - a pipeline describing the update, which may not be null.
      Since:
      3.11
      Since server release
      4.2
    • UpdateManyModel

      public UpdateManyModel(org.bson.conversions.Bson filter, List<? extends org.bson.conversions.Bson> update, UpdateOptions options)
      Construct a new instance.
      Parameters:
      filter - a document describing the query filter, which may not be null.
      update - a pipeline describing the update, which may not be null.
      options - the options to apply
      Since:
      3.11
      Since server release
      4.2
  • Method Details

    • getFilter

      public org.bson.conversions.Bson getFilter()
      Gets the query filter.
      Returns:
      the query filter
    • getUpdate

      @Nullable public org.bson.conversions.Bson getUpdate()
      Gets the document specifying the updates to apply to the matching document. The update to apply must include only update operators.
      Returns:
      the document specifying the updates to apply
    • getUpdatePipeline

      @Nullable public List<? extends org.bson.conversions.Bson> getUpdatePipeline()
      Gets the pipeline specifying the updates to apply to the matching document. The update to apply must include only update operators.
      Returns:
      the pipeline specifying the updates to apply
      Since:
      3.11
      Since server release
      4.2
    • getOptions

      public UpdateOptions getOptions()
      Gets the options to apply.
      Returns:
      the options
    • toString

      public String toString()
      Overrides:
      toString in class Object