|
|
|
@ -112,8 +112,8 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement |
|
|
|
Streamable<S> source = Streamable.of(entities); |
|
|
|
Streamable<S> source = Streamable.of(entities); |
|
|
|
|
|
|
|
|
|
|
|
return source.stream().allMatch(entityInformation::isNew) ? //
|
|
|
|
return source.stream().allMatch(entityInformation::isNew) ? //
|
|
|
|
mongoOperations.insert(source.stream().collect(Collectors.toList()), entityInformation.getCollectionName()) : //
|
|
|
|
insert(entities) : |
|
|
|
Flux.fromIterable(entities).flatMap(this::save); |
|
|
|
Flux.fromIterable(entities).concatMap(this::save); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -121,7 +121,7 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(entityStream, "The given Publisher of entities must not be null"); |
|
|
|
Assert.notNull(entityStream, "The given Publisher of entities must not be null"); |
|
|
|
|
|
|
|
|
|
|
|
return Flux.from(entityStream).flatMapSequential(entity -> entityInformation.isNew(entity) ? //
|
|
|
|
return Flux.from(entityStream).concatMap(entity -> entityInformation.isNew(entity) ? //
|
|
|
|
mongoOperations.insert(entity, entityInformation.getCollectionName()) : //
|
|
|
|
mongoOperations.insert(entity, entityInformation.getCollectionName()) : //
|
|
|
|
mongoOperations.save(entity, entityInformation.getCollectionName())); |
|
|
|
mongoOperations.save(entity, entityInformation.getCollectionName())); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -295,7 +295,7 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement |
|
|
|
Optional<ReadPreference> readPreference = getReadPreference(); |
|
|
|
Optional<ReadPreference> readPreference = getReadPreference(); |
|
|
|
return Flux.from(entityStream)//
|
|
|
|
return Flux.from(entityStream)//
|
|
|
|
.map(entityInformation::getRequiredId)//
|
|
|
|
.map(entityInformation::getRequiredId)//
|
|
|
|
.flatMap(id -> deleteById(id, readPreference))//
|
|
|
|
.concatMap(id -> deleteById(id, readPreference))//
|
|
|
|
.then(); |
|
|
|
.then(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -336,8 +336,7 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement |
|
|
|
Assert.notNull(entities, "The given Iterable of entities must not be null"); |
|
|
|
Assert.notNull(entities, "The given Iterable of entities must not be null"); |
|
|
|
|
|
|
|
|
|
|
|
Collection<S> source = toCollection(entities); |
|
|
|
Collection<S> source = toCollection(entities); |
|
|
|
|
|
|
|
return source.isEmpty() ? Flux.empty() : mongoOperations.insert(source, entityInformation.getCollectionName()); |
|
|
|
return source.isEmpty() ? Flux.empty() : mongoOperations.insertAll(source); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -345,8 +344,7 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement |
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(entities, "The given Publisher of entities must not be null"); |
|
|
|
Assert.notNull(entities, "The given Publisher of entities must not be null"); |
|
|
|
|
|
|
|
|
|
|
|
return Flux.from(entities) |
|
|
|
return Flux.from(entities).concatMap(this::insert); |
|
|
|
.flatMapSequential(entity -> mongoOperations.insert(entity, entityInformation.getCollectionName())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|