Search in sources :

Example 41 with DeleteResult

use of com.mongodb.client.result.DeleteResult in project mongo-java-driver by mongodb.

the class QuickTour method main.

/**
 * Run this main method to see the output of this quick example.
 *
 * @param args takes an optional single argument for the connection string
 */
public static void main(final String[] args) {
    MongoClient mongoClient;
    if (args.length == 0) {
        // connect to the local database server
        mongoClient = MongoClients.create();
    } else {
        mongoClient = MongoClients.create(args[0]);
    }
    // get handle to "mydb" database
    MongoDatabase database = mongoClient.getDatabase("mydb");
    // get a handle to the "test" collection
    final MongoCollection<Document> collection = database.getCollection("test");
    // drop all the data in it
    ObservableSubscriber<Void> successSubscriber = new OperationSubscriber<>();
    collection.drop().subscribe(successSubscriber);
    successSubscriber.await();
    // make a document and insert it
    Document doc = new Document("name", "MongoDB").append("type", "database").append("count", 1).append("info", new Document("x", 203).append("y", 102));
    ObservableSubscriber<InsertOneResult> insertOneSubscriber = new OperationSubscriber<>();
    collection.insertOne(doc).subscribe(insertOneSubscriber);
    insertOneSubscriber.await();
    // get it (since it's the only one in there since we dropped the rest earlier on)
    ObservableSubscriber<Document> documentSubscriber = new PrintDocumentSubscriber();
    collection.find().first().subscribe(documentSubscriber);
    documentSubscriber.await();
    // now, lets add lots of little documents to the collection so we can explore queries and cursors
    List<Document> documents = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        documents.add(new Document("i", i));
    }
    ObservableSubscriber<InsertManyResult> insertManySubscriber = new OperationSubscriber<>();
    collection.insertMany(documents).subscribe(insertManySubscriber);
    insertManySubscriber.await();
    // find first
    documentSubscriber = new PrintDocumentSubscriber();
    collection.find().first().subscribe(documentSubscriber);
    documentSubscriber.await();
    // lets get all the documents in the collection and print them out
    documentSubscriber = new PrintDocumentSubscriber();
    collection.find().subscribe(documentSubscriber);
    documentSubscriber.await();
    // Query Filters
    // now use a query to get 1 document out
    documentSubscriber = new PrintDocumentSubscriber();
    collection.find(eq("i", 71)).first().subscribe(documentSubscriber);
    documentSubscriber.await();
    // now use a range query to get a larger subset
    documentSubscriber = new PrintDocumentSubscriber();
    collection.find(gt("i", 50)).subscribe(documentSubscriber);
    successSubscriber.await();
    // range query with multiple constraints
    documentSubscriber = new PrintDocumentSubscriber();
    collection.find(and(gt("i", 50), lte("i", 100))).subscribe(documentSubscriber);
    successSubscriber.await();
    // Sorting
    documentSubscriber = new PrintDocumentSubscriber();
    collection.find(exists("i")).sort(descending("i")).first().subscribe(documentSubscriber);
    documentSubscriber.await();
    // Projection
    documentSubscriber = new PrintDocumentSubscriber();
    collection.find().projection(excludeId()).first().subscribe(documentSubscriber);
    documentSubscriber.await();
    // Aggregation
    documentSubscriber = new PrintDocumentSubscriber();
    collection.aggregate(asList(match(gt("i", 0)), project(Document.parse("{ITimes10: {$multiply: ['$i', 10]}}")))).subscribe(documentSubscriber);
    documentSubscriber.await();
    documentSubscriber = new PrintDocumentSubscriber();
    collection.aggregate(singletonList(group(null, sum("total", "$i")))).first().subscribe(documentSubscriber);
    documentSubscriber.await();
    // Update One
    ObservableSubscriber<UpdateResult> updateSubscriber = new OperationSubscriber<>();
    collection.updateOne(eq("i", 10), set("i", 110)).subscribe(updateSubscriber);
    updateSubscriber.await();
    // Update Many
    updateSubscriber = new OperationSubscriber<>();
    collection.updateMany(lt("i", 100), inc("i", 100)).subscribe(updateSubscriber);
    updateSubscriber.await();
    // Delete One
    ObservableSubscriber<DeleteResult> deleteSubscriber = new OperationSubscriber<>();
    collection.deleteOne(eq("i", 110)).subscribe(deleteSubscriber);
    deleteSubscriber.await();
    // Delete Many
    deleteSubscriber = new OperationSubscriber<>();
    collection.deleteMany(gte("i", 100)).subscribe(deleteSubscriber);
    deleteSubscriber.await();
    // Create Index
    OperationSubscriber<String> createIndexSubscriber = new PrintSubscriber<>("Create Index Result: %s");
    collection.createIndex(new Document("i", 1)).subscribe(createIndexSubscriber);
    createIndexSubscriber.await();
    // Clean up
    successSubscriber = new OperationSubscriber<>();
    collection.drop().subscribe(successSubscriber);
    successSubscriber.await();
    // release resources
    mongoClient.close();
}
Also used : PrintDocumentSubscriber(reactivestreams.helpers.SubscriberHelpers.PrintDocumentSubscriber) OperationSubscriber(reactivestreams.helpers.SubscriberHelpers.OperationSubscriber) ArrayList(java.util.ArrayList) Document(org.bson.Document) InsertManyResult(com.mongodb.client.result.InsertManyResult) MongoClient(com.mongodb.reactivestreams.client.MongoClient) PrintSubscriber(reactivestreams.helpers.SubscriberHelpers.PrintSubscriber) InsertOneResult(com.mongodb.client.result.InsertOneResult) UpdateResult(com.mongodb.client.result.UpdateResult) DeleteResult(com.mongodb.client.result.DeleteResult) MongoDatabase(com.mongodb.reactivestreams.client.MongoDatabase)

Example 42 with DeleteResult

use of com.mongodb.client.result.DeleteResult in project mongo-java-driver by mongodb.

the class GridFSPublisherCreator method createDeletePublisher.

public static Publisher<Void> createDeletePublisher(final MongoCollection<GridFSFile> filesCollection, final MongoCollection<Document> chunksCollection, @Nullable final ClientSession clientSession, final BsonValue id) {
    notNull("filesCollection", filesCollection);
    notNull("chunksCollection", chunksCollection);
    notNull("id", id);
    BsonDocument filter = new BsonDocument("_id", id);
    Publisher<DeleteResult> fileDeletePublisher;
    if (clientSession == null) {
        fileDeletePublisher = filesCollection.deleteOne(filter);
    } else {
        fileDeletePublisher = filesCollection.deleteOne(clientSession, filter);
    }
    return Mono.from(fileDeletePublisher).flatMap(deleteResult -> {
        if (deleteResult.wasAcknowledged() && deleteResult.getDeletedCount() == 0) {
            throw new MongoGridFSException(format("No file found with the ObjectId: %s", id));
        }
        if (clientSession == null) {
            return Mono.from(chunksCollection.deleteMany(new BsonDocument("files_id", id)));
        } else {
            return Mono.from(chunksCollection.deleteMany(clientSession, new BsonDocument("files_id", id)));
        }
    }).flatMap(i -> Mono.empty());
}
Also used : Document(org.bson.Document) GridFSFile(com.mongodb.client.gridfs.model.GridFSFile) Publisher(org.reactivestreams.Publisher) MongoGridFSException(com.mongodb.MongoGridFSException) Mono(reactor.core.publisher.Mono) MongoCollection(com.mongodb.reactivestreams.client.MongoCollection) ClientSession(com.mongodb.reactivestreams.client.ClientSession) BsonString(org.bson.BsonString) ByteBuffer(java.nio.ByteBuffer) String.format(java.lang.String.format) BsonDocument(org.bson.BsonDocument) BsonValue(org.bson.BsonValue) Bson(org.bson.conversions.Bson) GridFSUploadOptions(com.mongodb.client.gridfs.model.GridFSUploadOptions) Assertions.notNull(com.mongodb.assertions.Assertions.notNull) UpdateResult(com.mongodb.client.result.UpdateResult) GridFSDownloadOptions(com.mongodb.client.gridfs.model.GridFSDownloadOptions) FindPublisher(com.mongodb.reactivestreams.client.FindPublisher) DeleteResult(com.mongodb.client.result.DeleteResult) GridFSFindPublisher(com.mongodb.reactivestreams.client.gridfs.GridFSFindPublisher) Nullable(com.mongodb.lang.Nullable) BsonDocument(org.bson.BsonDocument) MongoGridFSException(com.mongodb.MongoGridFSException) DeleteResult(com.mongodb.client.result.DeleteResult)

Example 43 with DeleteResult

use of com.mongodb.client.result.DeleteResult in project spring-data-mongodb by spring-projects.

the class ExecutableRemoveOperationSupportTests method removeAllMatching.

// DATAMONGO-1563
@Test
void removeAllMatching() {
    DeleteResult result = template.remove(Person.class).matching(query(where("firstname").is("han"))).all();
    assertThat(result.getDeletedCount()).isEqualTo(1L);
}
Also used : DeleteResult(com.mongodb.client.result.DeleteResult) Test(org.junit.jupiter.api.Test)

Example 44 with DeleteResult

use of com.mongodb.client.result.DeleteResult in project spring-data-mongodb by spring-projects.

the class ReactiveMongoTemplate method doRemove.

protected <T> Mono<DeleteResult> doRemove(String collectionName, Query query, @Nullable Class<T> entityClass) {
    if (query == null) {
        throw new InvalidDataAccessApiUsageException("Query passed in to remove can't be null!");
    }
    Assert.hasText(collectionName, "Collection name must not be null or empty!");
    MongoPersistentEntity<?> entity = getPersistentEntity(entityClass);
    DeleteContext deleteContext = queryOperations.deleteQueryContext(query);
    Document queryObject = deleteContext.getMappedQuery(entity);
    DeleteOptions deleteOptions = deleteContext.getDeleteOptions(entityClass);
    Document removeQuery = deleteContext.getMappedQuery(entity);
    MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.REMOVE, collectionName, entityClass, null, removeQuery);
    WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction);
    return execute(collectionName, collection -> {
        maybeEmitEvent(new BeforeDeleteEvent<>(removeQuery, entityClass, collectionName));
        MongoCollection<Document> collectionToUse = prepareCollection(collection, writeConcernToUse);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(String.format("Remove using query: %s in collection: %s.", serializeToJsonSafely(removeQuery), collectionName));
        }
        if (query.getLimit() > 0 || query.getSkip() > 0) {
            FindPublisher<Document> cursor = new QueryFindPublisherPreparer(query, entityClass).prepare(// 
            collection.find(removeQuery)).projection(MappedDocument.getIdOnlyProjection());
            return // 
            Flux.from(cursor).map(// 
            MappedDocument::of).map(// 
            MappedDocument::getId).collectList().flatMapMany(val -> {
                return collectionToUse.deleteMany(MappedDocument.getIdIn(val), deleteOptions);
            });
        } else {
            return collectionToUse.deleteMany(removeQuery, deleteOptions);
        }
    }).doOnNext(// 
    it -> maybeEmitEvent(new AfterDeleteEvent<>(queryObject, entityClass, collectionName))).next();
}
Also used : Document(org.bson.Document) Arrays(java.util.Arrays) BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) NumberUtils(org.springframework.util.NumberUtils) BsonUtils(org.springframework.data.mongodb.util.BsonUtils) Tuples(reactor.util.function.Tuples) MongoCollection(com.mongodb.reactivestreams.client.MongoCollection) ReactiveMongoDatabaseUtils(org.springframework.data.mongodb.ReactiveMongoDatabaseUtils) FullDocument(com.mongodb.client.model.changestream.FullDocument) QueryContext(org.springframework.data.mongodb.core.QueryOperations.QueryContext) Optionals(org.springframework.data.util.Optionals) UpdateResult(com.mongodb.client.result.UpdateResult) Map(java.util.Map) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) CursorOption(org.springframework.data.mongodb.core.query.Meta.CursorOption) MongoJsonSchemaMapper(org.springframework.data.mongodb.core.convert.MongoJsonSchemaMapper) AggregationOperationContext(org.springframework.data.mongodb.core.aggregation.AggregationOperationContext) ClassUtils(org.springframework.util.ClassUtils) NearQuery(org.springframework.data.mongodb.core.query.NearQuery) MappingContextEvent(org.springframework.data.mapping.context.MappingContextEvent) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) CollectionUtils(org.springframework.util.CollectionUtils) FindPublisher(com.mongodb.reactivestreams.client.FindPublisher) LogFactory(org.apache.commons.logging.LogFactory) DistinctQueryContext(org.springframework.data.mongodb.core.QueryOperations.DistinctQueryContext) ApplicationContextAware(org.springframework.context.ApplicationContextAware) Validator(org.springframework.data.mongodb.core.validation.Validator) MongoCustomConversions(org.springframework.data.mongodb.core.convert.MongoCustomConversions) MappingContext(org.springframework.data.mapping.context.MappingContext) ArrayList(java.util.ArrayList) UpdateDefinition(org.springframework.data.mongodb.core.query.UpdateDefinition) MongoClient(com.mongodb.reactivestreams.client.MongoClient) Bson(org.bson.conversions.Bson) NoOpDbRefResolver(org.springframework.data.mongodb.core.convert.NoOpDbRefResolver) ReactiveMongoPersistentEntityIndexCreator(org.springframework.data.mongodb.core.index.ReactiveMongoPersistentEntityIndexCreator) DbRefResolver(org.springframework.data.mongodb.core.convert.DbRefResolver) MappingException(org.springframework.data.mapping.MappingException) MongoDatabase(com.mongodb.reactivestreams.client.MongoDatabase) Nullable(org.springframework.lang.Nullable) JsonSchemaMapper(org.springframework.data.mongodb.core.convert.JsonSchemaMapper) MongoSimpleTypes(org.springframework.data.mongodb.core.mapping.MongoSimpleTypes) com.mongodb.client.model(com.mongodb.client.model) PrefixingDelegatingAggregationOperationContext(org.springframework.data.mongodb.core.aggregation.PrefixingDelegatingAggregationOperationContext) CountContext(org.springframework.data.mongodb.core.QueryOperations.CountContext) ReactiveIndexOperations(org.springframework.data.mongodb.core.index.ReactiveIndexOperations) org.springframework.data.mongodb.core.mapping.event(org.springframework.data.mongodb.core.mapping.event) QueryMapper(org.springframework.data.mongodb.core.convert.QueryMapper) Publisher(org.reactivestreams.Publisher) ObjectUtils(org.springframework.util.ObjectUtils) DeleteContext(org.springframework.data.mongodb.core.QueryOperations.DeleteContext) TypedAggregation(org.springframework.data.mongodb.core.aggregation.TypedAggregation) Mono(reactor.core.publisher.Mono) BeansException(org.springframework.beans.BeansException) MongoMappingEventPublisher(org.springframework.data.mongodb.core.index.MongoMappingEventPublisher) RelaxedTypeBasedAggregationOperationContext(org.springframework.data.mongodb.core.aggregation.RelaxedTypeBasedAggregationOperationContext) ResourceUtils(org.springframework.util.ResourceUtils) Flux(reactor.core.publisher.Flux) ObjectId(org.bson.types.ObjectId) Collation(org.springframework.data.mongodb.core.query.Collation) EntityProjection(org.springframework.data.projection.EntityProjection) BsonValue(org.bson.BsonValue) PersistenceExceptionTranslator(org.springframework.dao.support.PersistenceExceptionTranslator) OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) MapReduceOptions(org.springframework.data.mongodb.core.mapreduce.MapReduceOptions) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AdaptibleEntity(org.springframework.data.mongodb.core.EntityOperations.AdaptibleEntity) CursorType(com.mongodb.CursorType) MongoWriter(org.springframework.data.mongodb.core.convert.MongoWriter) Meta(org.springframework.data.mongodb.core.query.Meta) ReactiveEntityCallbacks(org.springframework.data.mapping.callback.ReactiveEntityCallbacks) InsertOneResult(com.mongodb.client.result.InsertOneResult) SerializationUtils(org.springframework.data.mongodb.core.query.SerializationUtils) MongoException(com.mongodb.MongoException) Collection(java.util.Collection) ApplicationListener(org.springframework.context.ApplicationListener) Collectors(java.util.stream.Collectors) PersistentEntity(org.springframework.data.mapping.PersistentEntity) List(java.util.List) Optional(java.util.Optional) UpdateMapper(org.springframework.data.mongodb.core.convert.UpdateMapper) ReactiveMongoDatabaseFactory(org.springframework.data.mongodb.ReactiveMongoDatabaseFactory) TypeBasedAggregationOperationContext(org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext) UpdateContext(org.springframework.data.mongodb.core.QueryOperations.UpdateContext) Metric(org.springframework.data.geo.Metric) ReadPreference(com.mongodb.ReadPreference) DataAccessException(org.springframework.dao.DataAccessException) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MongoPersistentProperty(org.springframework.data.mongodb.core.mapping.MongoPersistentProperty) Tuple2(reactor.util.function.Tuple2) HashMap(java.util.HashMap) InvalidDataAccessApiUsageException(org.springframework.dao.InvalidDataAccessApiUsageException) DistinctPublisher(com.mongodb.reactivestreams.client.DistinctPublisher) MongoDatabaseFactory(org.springframework.data.mongodb.MongoDatabaseFactory) MongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter) Function(java.util.function.Function) Distance(org.springframework.data.geo.Distance) EntityReader(org.springframework.data.convert.EntityReader) ChangeStreamPublisher(com.mongodb.reactivestreams.client.ChangeStreamPublisher) ArrayFilter(org.springframework.data.mongodb.core.query.UpdateDefinition.ArrayFilter) Granularity(org.springframework.data.mongodb.core.timeseries.Granularity) MongoPersistentEntity(org.springframework.data.mongodb.core.mapping.MongoPersistentEntity) AggregationDefinition(org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition) Subscriber(org.reactivestreams.Subscriber) ApplicationEventPublisherAware(org.springframework.context.ApplicationEventPublisherAware) Iterator(java.util.Iterator) AggregationOptions(org.springframework.data.mongodb.core.aggregation.AggregationOptions) MapReducePublisher(com.mongodb.reactivestreams.client.MapReducePublisher) ClientSession(com.mongodb.reactivestreams.client.ClientSession) ApplicationContext(org.springframework.context.ApplicationContext) Query(org.springframework.data.mongodb.core.query.Query) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) AggregatePublisher(com.mongodb.reactivestreams.client.AggregatePublisher) ClientSessionOptions(com.mongodb.ClientSessionOptions) DeleteResult(com.mongodb.client.result.DeleteResult) Log(org.apache.commons.logging.Log) GeoResult(org.springframework.data.geo.GeoResult) SessionSynchronization(org.springframework.data.mongodb.SessionSynchronization) WriteConcern(com.mongodb.WriteConcern) Collections(java.util.Collections) Assert(org.springframework.util.Assert) StringUtils(org.springframework.util.StringUtils) DeleteContext(org.springframework.data.mongodb.core.QueryOperations.DeleteContext) Document(org.bson.Document) FullDocument(com.mongodb.client.model.changestream.FullDocument) WriteConcern(com.mongodb.WriteConcern) InvalidDataAccessApiUsageException(org.springframework.dao.InvalidDataAccessApiUsageException)

Example 45 with DeleteResult

use of com.mongodb.client.result.DeleteResult in project spring-data-mongodb by spring-projects.

the class MongoTemplateTests method removeShouldConsiderSkipAndSort.

// DATAMONGO-1870
@Test
public void removeShouldConsiderSkipAndSort() {
    List<Sample> samples = // 
    IntStream.range(0, 100).mapToObj(// 
    i -> new Sample("id-" + i, i % 2 == 0 ? "stark" : "lannister")).collect(Collectors.toList());
    template.insertAll(samples);
    DeleteResult wr = template.remove(new Query().skip(25).with(Sort.by("field")), Sample.class);
    assertThat(wr.getDeletedCount()).isEqualTo(75L);
    assertThat(template.count(new Query(), Sample.class)).isEqualTo(25L);
    assertThat(template.count(query(where("field").is("lannister")), Sample.class)).isEqualTo(25L);
    assertThat(template.count(query(where("field").is("stark")), Sample.class)).isEqualTo(0L);
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Version(org.springframework.data.annotation.Version) CloseableIterator(org.springframework.data.util.CloseableIterator) Index(org.springframework.data.mongodb.core.index.Index) BigDecimal(java.math.BigDecimal) AbstractMongoEventListener(org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener) OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) DBObject(com.mongodb.DBObject) UpdateResult(com.mongodb.client.result.UpdateResult) Duration(java.time.Duration) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Assertions(org.assertj.core.api.Assertions) Update(org.springframework.data.mongodb.core.query.Update) BigInteger(java.math.BigInteger) Sort(org.springframework.data.domain.Sort) ClassUtils(org.springframework.util.ClassUtils) With(lombok.With) MongoException(com.mongodb.MongoException) PageRequest(org.springframework.data.domain.PageRequest) EqualsAndHashCode(lombok.EqualsAndHashCode) Instant(java.time.Instant) IndexField(org.springframework.data.mongodb.core.index.IndexField) Collectors(java.util.stream.Collectors) Client(org.springframework.data.mongodb.test.util.Client) InvocationTargetException(java.lang.reflect.InvocationTargetException) Test(org.junit.jupiter.api.Test) InvalidMongoDbApiUsageException(org.springframework.data.mongodb.InvalidMongoDbApiUsageException) FindIterable(com.mongodb.client.FindIterable) Id(org.springframework.data.annotation.Id) ListIndexesIterable(com.mongodb.client.ListIndexesIterable) GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint) IntStream(java.util.stream.IntStream) ReadPreference(com.mongodb.ReadPreference) java.util(java.util) DataAccessException(org.springframework.dao.DataAccessException) PersistenceConstructor(org.springframework.data.annotation.PersistenceConstructor) MongoClient(com.mongodb.client.MongoClient) MongoCollection(com.mongodb.client.MongoCollection) InvalidDataAccessApiUsageException(org.springframework.dao.InvalidDataAccessApiUsageException) MongoDatabaseFactory(org.springframework.data.mongodb.MongoDatabaseFactory) MongoId(org.springframework.data.mongodb.core.mapping.MongoId) AtomicReference(java.util.concurrent.atomic.AtomicReference) Value(lombok.Value) Filters(com.mongodb.client.model.Filters) MappingException(org.springframework.data.mapping.MappingException) MongoCursor(com.mongodb.client.MongoCursor) Direction(org.springframework.data.domain.Sort.Direction) IndexInfo(org.springframework.data.mongodb.core.index.IndexInfo) BeforeConvertEvent(org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent) BeforeSaveEvent(org.springframework.data.mongodb.core.mapping.event.BeforeSaveEvent) Converter(org.springframework.core.convert.converter.Converter) LazyLoadingProxy(org.springframework.data.mongodb.core.convert.LazyLoadingProxy) ObjectUtils(org.springframework.util.ObjectUtils) DateTime(org.joda.time.DateTime) BasicDBObject(com.mongodb.BasicDBObject) IndexOptions(com.mongodb.client.model.IndexOptions) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) LastModifiedDate(org.springframework.data.annotation.LastModifiedDate) Criteria(org.springframework.data.mongodb.core.query.Criteria) Query(org.springframework.data.mongodb.core.query.Query) Field(org.springframework.data.mongodb.core.mapping.Field) MongoVersion(org.springframework.data.mongodb.test.util.MongoVersion) AfterEach(org.junit.jupiter.api.AfterEach) DuplicateKeyException(org.springframework.dao.DuplicateKeyException) AfterSaveEvent(org.springframework.data.mongodb.core.mapping.event.AfterSaveEvent) ChronoUnit(java.time.temporal.ChronoUnit) MongoTestTemplate(org.springframework.data.mongodb.test.util.MongoTestTemplate) DBRef(com.mongodb.DBRef) Data(lombok.Data) IsNewAwareAuditingHandler(org.springframework.data.auditing.IsNewAwareAuditingHandler) ObjectId(org.bson.types.ObjectId) DeleteResult(com.mongodb.client.result.DeleteResult) AllArgsConstructor(lombok.AllArgsConstructor) WriteConcern(com.mongodb.WriteConcern) MongoClientExtension(org.springframework.data.mongodb.test.util.MongoClientExtension) NoArgsConstructor(lombok.NoArgsConstructor) StringUtils(org.springframework.util.StringUtils) BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) Query(org.springframework.data.mongodb.core.query.Query) DeleteResult(com.mongodb.client.result.DeleteResult) Test(org.junit.jupiter.api.Test)

Aggregations

DeleteResult (com.mongodb.client.result.DeleteResult)46 Document (org.bson.Document)20 UpdateResult (com.mongodb.client.result.UpdateResult)10 BsonDocument (org.bson.BsonDocument)9 Test (org.junit.jupiter.api.Test)9 BasicDBObject (com.mongodb.BasicDBObject)7 WriteConcern (com.mongodb.WriteConcern)6 Bson (org.bson.conversions.Bson)6 MongoException (com.mongodb.MongoException)5 ArrayList (java.util.ArrayList)5 DataAccessException (org.springframework.dao.DataAccessException)5 MongoGridFSException (com.mongodb.MongoGridFSException)4 MongoClient (com.mongodb.client.MongoClient)4 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)4 ReadPreference (com.mongodb.ReadPreference)3 MongoDatabase (com.mongodb.client.MongoDatabase)3 InsertOneResult (com.mongodb.client.result.InsertOneResult)3 MongoClient (com.mongodb.reactivestreams.client.MongoClient)3 MongoDatabase (com.mongodb.reactivestreams.client.MongoDatabase)3 ObjectId (org.bson.types.ObjectId)3