Skip to content

Commit 00aac43

Browse files
committed
Specify a pipeline to an update command
JAVA-3254
1 parent fd166ed commit 00aac43

File tree

48 files changed

+1537
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1537
-118
lines changed

config/checkstyle-exclude.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
<!--DBCollection is insanely long, and we should not compromise every class length for this one-->
6464
<suppress checks="FileLength" files="DBCollection"/>
65+
<suppress checks="FileLength" files="MongoCollection"/>
6566

6667
<suppress checks="ParameterNumber" files="Connection"/>
6768
<suppress checks="ParameterNumber" files="DefaultServer"/>

driver-async/src/main/com/mongodb/async/client/MongoCollection.java

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,84 @@ void replaceOne(ClientSession clientSession, Bson filter, TDocument replacement,
12371237
void updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOptions options,
12381238
SingleResultCallback<UpdateResult> callback);
12391239

1240+
/**
1241+
* Update a single document in the collection according to the specified arguments.
1242+
*
1243+
* <p>Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.</p>
1244+
* @param filter a document describing the query filter, which may not be null.
1245+
* @param update a pipeline describing the update, which may not be null.
1246+
* @param callback the callback passed the result of the update one operation
1247+
* @throws com.mongodb.MongoWriteException if the write failed due some other failure specific to the update command
1248+
* @throws com.mongodb.MongoWriteConcernException if the write failed due being unable to fulfil the write concern
1249+
* @throws com.mongodb.MongoCommandException via the callback if the write failed due to a specific command exception
1250+
* @throws com.mongodb.MongoException if the write failed due some other failure
1251+
* @since 3.11
1252+
* @mongodb.server.release 4.2
1253+
* @mongodb.driver.manual tutorial/modify-documents/ Updates
1254+
* @mongodb.driver.manual reference/operator/update/ Update Operators
1255+
*/
1256+
void updateOne(Bson filter, List<? extends Bson> update, SingleResultCallback<UpdateResult> callback);
1257+
1258+
/**
1259+
* Update a single document in the collection according to the specified arguments.
1260+
*
1261+
* <p>Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.</p>
1262+
* @param filter a document describing the query filter, which may not be null.
1263+
* @param update a pipeline describing the update, which may not be null.
1264+
* @param updateOptions the options to apply to the update operation
1265+
* @param callback the callback passed the result of the update one operation
1266+
* @throws com.mongodb.MongoWriteException if the write failed due some other failure specific to the update command
1267+
* @throws com.mongodb.MongoWriteConcernException if the write failed due being unable to fulfil the write concern
1268+
* @throws com.mongodb.MongoCommandException via the callback if the write failed due to a specific command exception
1269+
* @throws com.mongodb.MongoException if the write failed due some other failure
1270+
* @since 3.11
1271+
* @mongodb.server.release 4.2
1272+
* @mongodb.driver.manual tutorial/modify-documents/ Updates
1273+
* @mongodb.driver.manual reference/operator/update/ Update Operators
1274+
*/
1275+
void updateOne(Bson filter, List<? extends Bson> update, UpdateOptions updateOptions,
1276+
SingleResultCallback<UpdateResult> callback);
1277+
1278+
/**
1279+
* Update a single document in the collection according to the specified arguments.
1280+
*
1281+
* <p>Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.</p>
1282+
* @param clientSession the client session with which to associate this operation
1283+
* @param filter a document describing the query filter, which may not be null.
1284+
* @param update a pipeline describing the update, which may not be null.
1285+
* @param callback the callback passed the result of the update one operation
1286+
* @throws com.mongodb.MongoWriteException if the write failed due some other failure specific to the update command
1287+
* @throws com.mongodb.MongoWriteConcernException if the write failed due being unable to fulfil the write concern
1288+
* @throws com.mongodb.MongoCommandException via the callback if the write failed due to a specific command exception
1289+
* @throws com.mongodb.MongoException if the write failed due some other failure
1290+
* @since 3.11
1291+
* @mongodb.server.release 4.2
1292+
* @mongodb.driver.manual tutorial/modify-documents/ Updates
1293+
* @mongodb.driver.manual reference/operator/update/ Update Operators
1294+
*/
1295+
void updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update, SingleResultCallback<UpdateResult> callback);
1296+
1297+
/**
1298+
* Update a single document in the collection according to the specified arguments.
1299+
*
1300+
* <p>Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.</p>
1301+
* @param clientSession the client session with which to associate this operation
1302+
* @param filter a document describing the query filter, which may not be null.
1303+
* @param update a pipeline describing the update, which may not be null.
1304+
* @param updateOptions the options to apply to the update operation
1305+
* @param callback the callback passed the result of the update one operation
1306+
* @throws com.mongodb.MongoWriteException if the write failed due some other failure specific to the update command
1307+
* @throws com.mongodb.MongoWriteConcernException if the write failed due being unable to fulfil the write concern
1308+
* @throws com.mongodb.MongoCommandException via the callback if the write failed due to a specific command exception
1309+
* @throws com.mongodb.MongoException if the write failed due some other failure
1310+
* @since 3.11
1311+
* @mongodb.server.release 4.2
1312+
* @mongodb.driver.manual tutorial/modify-documents/ Updates
1313+
* @mongodb.driver.manual reference/operator/update/ Update Operators
1314+
*/
1315+
void updateOne(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions updateOptions,
1316+
SingleResultCallback<UpdateResult> callback);
1317+
12401318
/**
12411319
* Update all documents in the collection according to the specified arguments.
12421320
*
@@ -1306,6 +1384,75 @@ void updateOne(ClientSession clientSession, Bson filter, Bson update, UpdateOpti
13061384
void updateMany(ClientSession clientSession, Bson filter, Bson update, UpdateOptions options,
13071385
SingleResultCallback<UpdateResult> callback);
13081386

1387+
/**
1388+
* Update all documents in the collection according to the specified arguments.
1389+
*
1390+
* @param filter a document describing the query filter, which may not be null.
1391+
* @param update a pipeline describing the update, which may not be null.
1392+
* @param callback the callback passed the result of the update many operation
1393+
* @throws com.mongodb.MongoWriteException if the write failed due some other failure specific to the update command
1394+
* @throws com.mongodb.MongoWriteConcernException if the write failed due being unable to fulfil the write concern
1395+
* @throws com.mongodb.MongoException if the write failed due some other failure
1396+
* @since 3.11
1397+
* @mongodb.server.release 4.2
1398+
* @mongodb.driver.manual tutorial/modify-documents/ Updates
1399+
* @mongodb.driver.manual reference/operator/update/ Update Operators
1400+
*/
1401+
void updateMany(Bson filter, List<? extends Bson> update, SingleResultCallback<UpdateResult> callback);
1402+
1403+
/**
1404+
* Update all documents in the collection according to the specified arguments.
1405+
*
1406+
* @param filter a document describing the query filter, which may not be null.
1407+
* @param update a pipeline describing the update, which may not be null.
1408+
* @param updateOptions the options to apply to the update operation
1409+
* @param callback the callback passed the result of the update many operation
1410+
* @throws com.mongodb.MongoWriteException if the write failed due some other failure specific to the update command
1411+
* @throws com.mongodb.MongoWriteConcernException if the write failed due being unable to fulfil the write concern
1412+
* @throws com.mongodb.MongoException if the write failed due some other failure
1413+
* @since 3.11
1414+
* @mongodb.server.release 4.2
1415+
* @mongodb.driver.manual tutorial/modify-documents/ Updates
1416+
* @mongodb.driver.manual reference/operator/update/ Update Operators
1417+
*/
1418+
void updateMany(Bson filter, List<? extends Bson> update, UpdateOptions updateOptions, SingleResultCallback<UpdateResult> callback);
1419+
1420+
/**
1421+
* Update all documents in the collection according to the specified arguments.
1422+
*
1423+
* @param clientSession the client session with which to associate this operation
1424+
* @param filter a document describing the query filter, which may not be null.
1425+
* @param update a pipeline describing the update, which may not be null.
1426+
* @param callback the callback passed the result of the update many operation
1427+
* @throws com.mongodb.MongoWriteException if the write failed due some other failure specific to the update command
1428+
* @throws com.mongodb.MongoWriteConcernException if the write failed due being unable to fulfil the write concern
1429+
* @throws com.mongodb.MongoException if the write failed due some other failure
1430+
* @since 3.11
1431+
* @mongodb.server.release 4.2
1432+
* @mongodb.driver.manual tutorial/modify-documents/ Updates
1433+
* @mongodb.driver.manual reference/operator/update/ Update Operators
1434+
*/
1435+
void updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update, SingleResultCallback<UpdateResult> callback);
1436+
1437+
/**
1438+
* Update all documents in the collection according to the specified arguments.
1439+
*
1440+
* @param clientSession the client session with which to associate this operation
1441+
* @param filter a document describing the query filter, which may not be null.
1442+
* @param update a pipeline describing the update, which may not be null.
1443+
* @param updateOptions the options to apply to the update operation
1444+
* @param callback the callback passed the result of the update many operation
1445+
* @throws com.mongodb.MongoWriteException if the write failed due some other failure specific to the update command
1446+
* @throws com.mongodb.MongoWriteConcernException if the write failed due being unable to fulfil the write concern
1447+
* @throws com.mongodb.MongoException if the write failed due some other failure
1448+
* @since 3.11
1449+
* @mongodb.server.release 4.2
1450+
* @mongodb.driver.manual tutorial/modify-documents/ Updates
1451+
* @mongodb.driver.manual reference/operator/update/ Update Operators
1452+
*/
1453+
void updateMany(ClientSession clientSession, Bson filter, List<? extends Bson> update, UpdateOptions updateOptions,
1454+
SingleResultCallback<UpdateResult> callback);
1455+
13091456
/**
13101457
* Atomically find a document and remove it.
13111458
*
@@ -1466,6 +1613,66 @@ void findOneAndReplace(ClientSession clientSession, Bson filter, TDocument repla
14661613
void findOneAndUpdate(ClientSession clientSession, Bson filter, Bson update, FindOneAndUpdateOptions options,
14671614
SingleResultCallback<TDocument> callback);
14681615

1616+
/**
1617+
* Atomically find a document and update it.
1618+
*
1619+
* <p>Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.</p>
1620+
* @param filter a document describing the query filter, which may not be null.
1621+
* @param update a pipeline describing the update, which may not be null.
1622+
* @param callback the callback passed the document that was updated before the update was applied. If no documents matched the query
1623+
* filter, then null will be returned
1624+
* @since 3.11
1625+
* @mongodb.server.release 4.2
1626+
*/
1627+
void findOneAndUpdate(Bson filter, List<? extends Bson> update, SingleResultCallback<TDocument> callback);
1628+
1629+
/**
1630+
* Atomically find a document and update it.
1631+
*
1632+
* <p>Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.</p>
1633+
* @param filter a document describing the query filter, which may not be null.
1634+
* @param update a pipeline describing the update, which may not be null.
1635+
* @param options the options to apply to the operation
1636+
* @param callback the callback passed the document that was updated. Depending on the value of the {@code returnOriginal} property,
1637+
* this will either be the document as it was before the update or as it is after the update. If no documents matched
1638+
* the query filter, then null will be returned
1639+
* @since 3.11
1640+
* @mongodb.server.release 4.2
1641+
*/
1642+
void findOneAndUpdate(Bson filter, List<? extends Bson> update, FindOneAndUpdateOptions options,
1643+
SingleResultCallback<TDocument> callback);
1644+
1645+
/**
1646+
* Atomically find a document and update it.
1647+
*
1648+
* <p>Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.</p>
1649+
* @param clientSession the client session with which to associate this operation
1650+
* @param filter a document describing the query filter, which may not be null.
1651+
* @param update a pipeline describing the update, which may not be null.
1652+
* @param callback the callback passed the document that was updated before the update was applied. If no documents matched the query
1653+
* filter, then null will be returned
1654+
* @since 3.11
1655+
* @mongodb.server.release 4.2
1656+
*/
1657+
void findOneAndUpdate(ClientSession clientSession, Bson filter, List<? extends Bson> update, SingleResultCallback<TDocument> callback);
1658+
1659+
/**
1660+
* Atomically find a document and update it.
1661+
*
1662+
* <p>Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.</p>
1663+
* @param clientSession the client session with which to associate this operation
1664+
* @param filter a document describing the query filter, which may not be null.
1665+
* @param update a pipeline describing the update, which may not be null.
1666+
* @param options the options to apply to the operation
1667+
* @param callback the callback passed the document that was updated. Depending on the value of the {@code returnOriginal} property,
1668+
* this will either be the document as it was before the update or as it is after the update. If no documents matched
1669+
* the query filter, then null will be returned
1670+
* @since 3.11
1671+
* @mongodb.server.release 4.2
1672+
*/
1673+
void findOneAndUpdate(ClientSession clientSession, Bson filter, List<? extends Bson> update, FindOneAndUpdateOptions options,
1674+
SingleResultCallback<TDocument> callback);
1675+
14691676
/**
14701677
* Drops this collection from the Database.
14711678
*

0 commit comments

Comments
 (0)