public WriteResult update ( final DBObject query , final DBObject update , final DBCollectionUpdateOptions options ) { notNull ( "query" , query ) ; notNull ( "update" , update ) ; notNull ( "options" , options ) ; WriteConcern writeConcern = options . getWriteConcern ( ) != null ? options . getWriteConcern ( ) : getWriteConcern ( ) ; com . mongodb . bulk . WriteRequest . Type updateType = ! update . keySet ( ) . isEmpty ( ) && update . keySet ( ) . iterator ( ) . next ( ) . startsWith ( "$" ) ? com . mongodb . bulk . WriteRequest . Type . UPDATE : com . mongodb . bulk . WriteRequest . Type . REPLACE ; UpdateRequest updateRequest = new UpdateRequest ( wrap ( query ) , wrap ( update , options . getEncoder ( ) ) , updateType ) . upsert ( options . isUpsert ( ) ) . multi ( options . isMulti ( ) ) . collation ( options . getCollation ( ) ) . arrayFilters ( wrapAllowNull ( options . getArrayFilters ( ) , options . getEncoder ( ) ) ) ; return executeWriteOperation ( new UpdateOperation ( getNamespace ( ) , true , writeConcern , retryWrites , singletonList ( updateRequest ) ) . bypassDocumentValidation ( options . getBypassDocumentValidation ( ) ) ) ; }
Modify an existing document or documents in collection .