类com.mongodb.client.result.InsertOneResult源码实例Demo

下面列出了怎么用com.mongodb.client.result.InsertOneResult的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: enode   文件: MongoEventStore.java
public CompletableFuture<AggregateEventAppendResult> insertOneByOneAsync(List<Document> documents) {
    CompletableFuture<AggregateEventAppendResult> future = new CompletableFuture<>();
    CountDownLatch latch = new CountDownLatch(documents.size());
    for (Document document : documents) {
        mongoClient.getDatabase(mongoConfiguration.getDatabaseName()).getCollection(mongoConfiguration.getEventCollectionName())
                .insertOne(document).subscribe(new Subscriber<InsertOneResult>() {
            @Override
            public void onSubscribe(Subscription s) {
                s.request(1);
            }

            @Override
            public void onNext(InsertOneResult insertOneResult) {
                latch.countDown();
            }

            @Override
            public void onError(Throwable t) {
                latch.countDown();
                future.completeExceptionally(t);
            }

            @Override
            public void onComplete() {
                if (latch.getCount() == 0) {
                    AggregateEventAppendResult appendResult = new AggregateEventAppendResult();
                    appendResult.setEventAppendStatus(EventAppendStatus.Success);
                    future.complete(appendResult);
                }
            }
        });
        if (future.isDone()) {
            break;
        }
    }
    return future;
}
 
源代码2 项目: quarkus   文件: MongoTestBase.java
protected Uni<Void> insertDocs(ReactiveMongoClient mongoClient, String collection, int num) {
    io.quarkus.mongodb.reactive.ReactiveMongoDatabase database = mongoClient.getDatabase(DATABASE);
    io.quarkus.mongodb.reactive.ReactiveMongoCollection<Document> mongoCollection = database
            .getCollection(collection);
    List<CompletableFuture<InsertOneResult>> list = new ArrayList<>();
    for (int i = 0; i < num; i++) {
        Document doc = createDoc(i);
        list.add(mongoCollection.insertOne(doc).subscribeAsCompletionStage());
    }
    CompletableFuture<InsertOneResult>[] array = list.toArray(new CompletableFuture[0]);
    return Uni.createFrom().completionStage(CompletableFuture.allOf(array));
}
 
源代码3 项目: logging-log4j2   文件: MongoDb4Connection.java
@Override
public void insertObject(final NoSqlObject<Document> object) {
    try {
        final Document unwrapped = object.unwrap();
        LOGGER.debug("Inserting BSON Document {}", unwrapped);
        InsertOneResult insertOneResult = this.collection.insertOne(unwrapped);
        LOGGER.debug("Insert MongoDb result {}", insertOneResult);
    } catch (final MongoException e) {
        throw new AppenderLoggingException("Failed to write log event to MongoDB due to error: " + e.getMessage(),
                e);
    }
}
 
源代码4 项目: quarkus   文件: ReactiveMongoCollectionImpl.java
@Override
public Uni<InsertOneResult> insertOne(T t) {
    return Wrappers.toUni(collection.insertOne(t));
}
 
源代码5 项目: quarkus   文件: ReactiveMongoCollectionImpl.java
@Override
public Uni<InsertOneResult> insertOne(T t, InsertOneOptions options) {
    return Wrappers.toUni(collection.insertOne(t, options));
}
 
源代码6 项目: quarkus   文件: ReactiveMongoCollectionImpl.java
@Override
public Uni<InsertOneResult> insertOne(ClientSession clientSession, T t) {
    return Wrappers.toUni(collection.insertOne(clientSession, t));
}
 
源代码7 项目: quarkus   文件: ReactiveMongoCollectionImpl.java
@Override
public Uni<InsertOneResult> insertOne(ClientSession clientSession, T t, InsertOneOptions options) {
    return Wrappers.toUni(collection.insertOne(clientSession, t, options));
}
 
源代码8 项目: quarkus   文件: ReactiveMongoCollection.java
/**
 * Inserts the provided document. If the document is missing an identifier, the driver should generate one.
 *
 * @param document the document to insert
 * @return a {@link Uni} completed successfully when the operation completes, or propagating a
 *         {@link com.mongodb.DuplicateKeyException} or {@link com.mongodb.MongoException} on failure.
 */
Uni<InsertOneResult> insertOne(T document);
 
源代码9 项目: quarkus   文件: ReactiveMongoCollection.java
/**
 * Inserts the provided document. If the document is missing an identifier, the driver should generate one.
 *
 * @param document the document to insert
 * @param options the options to apply to the operation
 * @return a {@link Uni} completed successfully when the operation completes, or propagating a
 *         {@link com.mongodb.DuplicateKeyException} or {@link com.mongodb.MongoException} on failure.
 */
Uni<InsertOneResult> insertOne(T document, InsertOneOptions options);
 
源代码10 项目: quarkus   文件: ReactiveMongoCollection.java
/**
 * Inserts the provided document. If the document is missing an identifier, the driver should generate one.
 *
 * @param clientSession the client session with which to associate this operation
 * @param document the document to insert
 * @return a {@link Uni} completed successfully when the operation completes, or propagating a
 *         {@link com.mongodb.DuplicateKeyException} or {@link com.mongodb.MongoException} on failure.
 */
Uni<InsertOneResult> insertOne(ClientSession clientSession, T document);
 
源代码11 项目: quarkus   文件: ReactiveMongoCollection.java
/**
 * Inserts the provided document. If the document is missing an identifier, the driver should generate one.
 *
 * @param clientSession the client session with which to associate this operation
 * @param document the document to insert
 * @param options the options to apply to the operation
 * @return a {@link Uni} completed successfully when the operation completes, or propagating a
 *         {@link com.mongodb.DuplicateKeyException} or {@link com.mongodb.MongoException} on failure.
 */
Uni<InsertOneResult> insertOne(ClientSession clientSession, T document, InsertOneOptions options);
 
 类所在包
 同包方法