List of usage examples for com.mongodb BulkWriteRequestBuilder updateOne
public void updateOne(final DBObject update)
From source file:org.springframework.data.mongodb.core.DefaultBulkOperations.java
License:Apache License
/** * Performs update and upsert bulk operations. * //from www . ja va2 s .com * @param query the {@link Query} to determine documents to update. * @param update the {@link Update} to perform, must not be {@literal null}. * @param upsert whether to upsert. * @param multi whether to issue a multi-update. * @return the {@link BulkOperations} with the update registered. */ private BulkOperations update(Query query, Update update, boolean upsert, boolean multi) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(update, "Update must not be null!"); BulkWriteRequestBuilder builder = bulk.find(query.getQueryObject()); if (upsert) { if (multi) { builder.upsert().update(update.getUpdateObject()); } else { builder.upsert().updateOne(update.getUpdateObject()); } } else { if (multi) { builder.update(update.getUpdateObject()); } else { builder.updateOne(update.getUpdateObject()); } } return this; }