use of com.mongodb.client.model.FindOneAndReplaceOptions in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method findAndReplaceShouldUseDefaultCollationWhenPresent.
// DATAMONGO-1854
@Test
void findAndReplaceShouldUseDefaultCollationWhenPresent() {
template.findAndReplace(new BasicQuery("{}"), new Sith());
ArgumentCaptor<FindOneAndReplaceOptions> options = ArgumentCaptor.forClass(FindOneAndReplaceOptions.class);
verify(collection).findOneAndReplace(any(), any(), options.capture());
assertThat(options.getValue().getCollation().getLocale()).isEqualTo("de_AT");
}
use of com.mongodb.client.model.FindOneAndReplaceOptions in project engine by Lumeer.
the class MongoViewDao method updateView.
@Override
public View updateView(final String id, final View view) {
JsonView jsonView = new JsonView(view);
FindOneAndReplaceOptions options = new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER);
try {
View updatedView = databaseCollection().findOneAndReplace(idFilter(id), jsonView, options);
if (updatedView == null) {
throw new StorageException("View '" + view.getId() + "' has not been updated.");
}
return updatedView;
} catch (MongoException ex) {
throw new StorageException("Cannot update view: " + view, ex);
}
}
use of com.mongodb.client.model.FindOneAndReplaceOptions in project engine by Lumeer.
the class MongoDataDao method updateData.
@Override
public DataDocument updateData(final String collectionId, final String documentId, final DataDocument data) {
Document document = new Document(data);
FindOneAndReplaceOptions options = new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER);
Document updatedDocument = dataCollection(collectionId).findOneAndReplace(idFilter(documentId), document, options);
if (updatedDocument == null) {
throw new StorageException("Document '" + documentId + "' has not been updated (replaced).");
}
return MongoUtils.convertDocument(updatedDocument);
}
Aggregations