use of com.mongodb.reactivestreams.client.Success in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplate method insertDBObject.
protected Mono<Object> insertDBObject(final String collectionName, final Document dbDoc, final Class<?> entityClass) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Inserting Document containing fields: " + dbDoc.keySet() + " in collection: " + collectionName);
}
final Document document = new Document(dbDoc);
Flux<Success> execute = execute(collectionName, collection -> {
MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.INSERT, collectionName, entityClass, dbDoc, null);
WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction);
MongoCollection<Document> collectionToUse = prepareCollection(collection, writeConcernToUse);
return collectionToUse.insertOne(document);
});
return Flux.from(execute).last().map(success -> document.get(ID_FIELD));
}
Aggregations