类com.mongodb.client.model.FindOneAndDeleteOptions源码实例Demo

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

源代码1 项目: quarkus   文件: CollectionManagementTest.java
@Test
void findAndDelete() {
    ReactiveMongoDatabase database = client.getDatabase(DATABASE);
    ReactiveMongoCollection<Document> collection = database.getCollection("test");

    CompletableFuture.allOf(
            collection
                    .insertOne(new Document("id", 1).append("name", "superman").append("type", "heroes")
                            .append("stars", 5))
                    .subscribeAsCompletionStage(),
            collection.insertOne(
                    new Document("id", 2).append("name", "batman").append("type", "heroes").append("stars", 4))
                    .subscribeAsCompletionStage(),
            collection
                    .insertOne(new Document("id", 3).append("name", "frogman").append("type", "villain")
                            .append("stars", 1))
                    .subscribeAsCompletionStage(),
            collection.insertOne(
                    new Document("id", 4).append("name", "joker").append("type", "villain").append("stars", 5))
                    .subscribeAsCompletionStage())
            .join();

    Document frogman = collection.findOneAndDelete(new Document("id", 3)).await().indefinitely();
    Document superman = collection
            .findOneAndDelete(new Document("id", 1), new FindOneAndDeleteOptions().sort(new Document("id", 1)))
            .await().indefinitely();

    assertThat(frogman).contains(entry("stars", 1), entry("name", "frogman"));
    assertThat(superman).contains(entry("stars", 5), entry("name", "superman"));

}
 
@Override
public Observable<TDocument> findOneAndDelete(final Bson filter, final FindOneAndDeleteOptions options) {
    return RxObservables.create(Observables.observe(new Block<SingleResultCallback<TDocument>>() {
        @Override
        public void apply(final SingleResultCallback<TDocument> callback) {
            wrapped.findOneAndDelete(filter, options, callback);
        }
    }), observableAdapter);
}
 
@Override
public Publisher<TDocument> findOneAndDelete(final Bson filter, final FindOneAndDeleteOptions options) {
    return new ObservableToPublisher<TDocument>(com.mongodb.async.client.Observables.observe(
            new Block<com.mongodb.async.SingleResultCallback<TDocument>>() {
                @Override
                public void apply(final com.mongodb.async.SingleResultCallback<TDocument> callback) {
                    wrapped.findOneAndDelete(filter, options, callback);
                }
            }));
}
 
@Override
public Publisher<TDocument> findOneAndDelete(final ClientSession clientSession, final Bson filter,
                                             final FindOneAndDeleteOptions options) {
    return new ObservableToPublisher<TDocument>(com.mongodb.async.client.Observables.observe(
            new Block<com.mongodb.async.SingleResultCallback<TDocument>>() {
                @Override
                public void apply(final com.mongodb.async.SingleResultCallback<TDocument> callback) {
                    wrapped.findOneAndDelete(clientSession.getWrapped(), filter, options, callback);
                }
            }));
}
 
源代码5 项目: immutables   文件: Repositories.java
protected final FluentFuture<Optional<T>> doFindOneAndDelete(
        final Constraints.ConstraintHost criteria,
        final FindOneAndDeleteOptions options) {

  checkNotNull(criteria, "criteria");
  checkNotNull(options, "options");

  return submit(new Callable<Optional<T>>() {
    @Override
    public Optional<T> call() throws Exception {
      @Nullable T result = collection().findOneAndDelete(convertToBson(criteria), options);
      return Optional.fromNullable(result);
    }
  });
}
 
源代码6 项目: immutables   文件: Repositories.java
/**
 * Deletes and returns first matching document. Returns {@link Optional#absent()} if none
 * documents matches.
 * @return future of optional matching deleted document.
 */
public FluentFuture<Optional<T>> deleteFirst() {
  checkState(numberToSkip == 0, "Cannot use .skip() with .deleteFirst()");
  FindOneAndDeleteOptions options = new FindOneAndDeleteOptions();
  options.sort(convertToBson(ordering));
  return repository.doFindOneAndDelete(criteria, options);
}
 
源代码7 项目: quarkus   文件: ReactiveMongoCollectionImpl.java
@Override
public Uni<T> findOneAndDelete(Bson filter, FindOneAndDeleteOptions options) {
    return Wrappers.toUni(collection.findOneAndDelete(filter, options));
}
 
源代码8 项目: quarkus   文件: ReactiveMongoCollectionImpl.java
@Override
public Uni<T> findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options) {
    return Wrappers.toUni(collection.findOneAndDelete(clientSession, filter, options));
}
 
@Override
public Observable<TDocument> findOneAndDelete(final Bson filter) {
    return findOneAndDelete(filter, new FindOneAndDeleteOptions());
}
 
@Override
public Publisher<TDocument> findOneAndDelete(final Bson filter) {
    return findOneAndDelete(filter, new FindOneAndDeleteOptions());
}
 
@Override
public Publisher<TDocument> findOneAndDelete(final ClientSession clientSession, final Bson filter) {
    return findOneAndDelete(clientSession, filter, new FindOneAndDeleteOptions());
}
 
源代码12 项目: morphia   文件: OptionsTest.java
@Test
public void findAndDeleteOptions() {
    scan(FindOneAndDeleteOptions.class, FindAndDeleteOptions.class, true, List.of(WriteConcern.class));
}
 
源代码13 项目: quarkus   文件: ReactiveMongoCollection.java
/**
 * Atomically find a document and remove it.
 *
 * @param filter the query filter to find the document with
 * @param options the options to apply to the operation
 * @return a {@link Uni} completed with the document that was removed. If no documents matched the query filter,
 *         then the uni is completed with {@code null}.
 */
Uni<T> findOneAndDelete(Bson filter, FindOneAndDeleteOptions options);
 
源代码14 项目: quarkus   文件: ReactiveMongoCollection.java
/**
 * Atomically find a document and remove it.
 *
 * @param clientSession the client session with which to associate this operation
 * @param filter the query filter to find the document with
 * @param options the options to apply to the operation
 * @return a {@link Uni} completed with the document that was removed. If no documents matched the query filter,
 *         then the uni is completed with {@code null}.
 */
Uni<T> findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options);
 
源代码15 项目: mongo-java-driver-rx   文件: MongoCollection.java
/**
 * Atomically find a document and remove it.
 *
 * @param filter  the query filter to find the document with
 * @param options the options to apply to the operation
 * @return an Observable with a single element the document that was removed.  If no documents matched the query filter, then the
 * observer will complete without emitting any items
 */
Observable<TDocument> findOneAndDelete(Bson filter, FindOneAndDeleteOptions options);
 
/**
 * Atomically find a document and remove it.
 *
 * @param filter  the query filter to find the document with
 * @param options the options to apply to the operation
 * @return a publisher with a single element the document that was removed.  If no documents matched the query filter, then null will be
 * returned
 */
Publisher<TDocument> findOneAndDelete(Bson filter, FindOneAndDeleteOptions options);
 
/**
 * Atomically find a document and remove it.
 *
 * @param clientSession the client session with which to associate this operation
 * @param filter  the query filter to find the document with
 * @param options the options to apply to the operation
 * @return a publisher with a single element the document that was removed.  If no documents matched the query filter, then null will be
 * returned
 * @mongodb.server.release 3.6
 * @since 1.7
 */
Publisher<TDocument> findOneAndDelete(ClientSession clientSession, Bson filter, FindOneAndDeleteOptions options);
 
 类所在包
 类方法
 同包方法