use of org.springframework.data.mongodb.core.mapping.Field in project spring-data-mongodb by spring-projects.
the class MongoTemplateTests method removeShouldConsiderLimit.
// DATAMONGO-1870
@Test
public void removeShouldConsiderLimit() {
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(query(where("field").is("lannister")).limit(25), Sample.class);
assertThat(wr.getDeletedCount()).isEqualTo(25L);
assertThat(template.count(new Query(), Sample.class)).isEqualTo(75L);
}
use of org.springframework.data.mongodb.core.mapping.Field 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);
}
Aggregations