com.mongodb.client.result.InsertOneResult Java Examples
The following examples show how to use
com.mongodb.client.result.InsertOneResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoEventStore.java From enode with MIT License | 5 votes |
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; }
Example #2
Source File: MongoTestBase.java From quarkus with Apache License 2.0 | 5 votes |
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)); }
Example #3
Source File: MongoDb4Connection.java From logging-log4j2 with Apache License 2.0 | 5 votes |
@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); } }
Example #4
Source File: ReactiveMongoCollectionImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Uni<InsertOneResult> insertOne(T t) { return Wrappers.toUni(collection.insertOne(t)); }
Example #5
Source File: ReactiveMongoCollectionImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Uni<InsertOneResult> insertOne(T t, InsertOneOptions options) { return Wrappers.toUni(collection.insertOne(t, options)); }
Example #6
Source File: ReactiveMongoCollectionImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Uni<InsertOneResult> insertOne(ClientSession clientSession, T t) { return Wrappers.toUni(collection.insertOne(clientSession, t)); }
Example #7
Source File: ReactiveMongoCollectionImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Uni<InsertOneResult> insertOne(ClientSession clientSession, T t, InsertOneOptions options) { return Wrappers.toUni(collection.insertOne(clientSession, t, options)); }
Example #8
Source File: ReactiveMongoCollection.java From quarkus with Apache License 2.0 | 2 votes |
/** * 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);
Example #9
Source File: ReactiveMongoCollection.java From quarkus with Apache License 2.0 | 2 votes |
/** * 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);
Example #10
Source File: ReactiveMongoCollection.java From quarkus with Apache License 2.0 | 2 votes |
/** * 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);
Example #11
Source File: ReactiveMongoCollection.java From quarkus with Apache License 2.0 | 2 votes |
/** * 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);