@Override public TDocument findOneAndDelete(Bson filter, FindOneAndDeleteOptions arg1) { OperationMetric metric = null; if (MongoLogger.GATHERER.isEnabled()) { List<String> keyValuePairs = MongoUtilities.getKeyValuePairs(filter); String operationName = "Mongo : " + getNamespace().getCollectionName() + " : findOneAndDelete " + MongoUtilities.filterParameters(filter).toString(); metric = startMetric(operationName, keyValuePairs); addWriteConcern(metric); addReadConcernAndPreference(metric); } TDocument retVal = collection.findOneAndDelete(filter, arg1); stopMetric(metric, measureDocumentSizeIfResultSizeEnabled(retVal)); return retVal; }
@Override public io.vertx.ext.mongo.MongoClient findOneAndDeleteWithOptions(String collection, JsonObject query, FindOptions findOptions, Handler<AsyncResult<JsonObject>> resultHandler) { requireNonNull(collection, "collection cannot be null"); requireNonNull(query, "query cannot be null"); requireNonNull(findOptions, "find options cannot be null"); requireNonNull(resultHandler, "resultHandler cannot be null"); JsonObject encodedQuery = encodeKeyWhenUseObjectId(query); Bson bquery = wrap(encodedQuery); FindOneAndDeleteOptions foadOptions = new FindOneAndDeleteOptions(); foadOptions.sort(wrap(findOptions.getSort())); foadOptions.projection(wrap(findOptions.getFields())); MongoCollection<JsonObject> coll = getCollection(collection); coll.findOneAndDelete(bquery, foadOptions, wrapCallback(resultHandler)); return this; }
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); } }); }
/** * 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); }
@Test public void findOneAndDelete() { insertOneWithBulk(); Assert.assertNotNull(coll.findOneAndDelete(Filters.eq("name", "DELETEME"))); insertOneWithBulk(); Assert.assertNotNull(coll.findOneAndDelete(Filters.eq("name", "DELETEME"), new FindOneAndDeleteOptions())); }
@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>(observe(new Block<SingleResultCallback<TDocument>>() { @Override public void apply(final 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>(observe(new Block<SingleResultCallback<TDocument>>() { @Override public void apply(final SingleResultCallback<TDocument> callback) { wrapped.findOneAndDelete(clientSession, filter, options, callback); } })); }
@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()); }
/** * 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);