FindAndDeleteOperation<TDocument> findOneAndDelete(final Bson filter, final FindOneAndDeleteOptions options) { return new FindAndDeleteOperation<TDocument>(namespace, writeConcern, retryWrites, getCodec()) .filter(toBsonDocument(filter)) .projection(toBsonDocument(options.getProjection())) .sort(toBsonDocument(options.getSort())) .maxTime(options.getMaxTime(MILLISECONDS), MILLISECONDS) .collation(options.getCollation()); }
@Override public BsonDocument create(final ServerDescription serverDescription, final ConnectionDescription connectionDescription) { validateCollation(connectionDescription, collation); BsonDocument commandDocument = new BsonDocument("findAndModify", new BsonString(getNamespace().getCollectionName())); putIfNotNull(commandDocument, "query", getFilter()); putIfNotNull(commandDocument, "fields", getProjection()); putIfNotNull(commandDocument, "sort", getSort()); putIfNotZero(commandDocument, "maxTimeMS", getMaxTime(MILLISECONDS)); commandDocument.put("remove", BsonBoolean.TRUE); addWriteConcernToCommand(connectionDescription, commandDocument, sessionContext); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } addTxnNumberToCommand(serverDescription, connectionDescription, commandDocument, sessionContext); return commandDocument; } };
WriteOperation<DBObject> operation; if (options.isRemove()) { operation = new FindAndDeleteOperation<DBObject>(getNamespace(), writeConcern, retryWrites, objectCodec) .filter(wrapAllowNull(query)) .projection(wrapAllowNull(options.getProjection())) .sort(wrapAllowNull(options.getSort())) .maxTime(options.getMaxTime(MILLISECONDS), MILLISECONDS) .collation(options.getCollation()); } else { DBObject update = options.getUpdate();
@Override public BsonDocument create(final ServerDescription serverDescription, final ConnectionDescription connectionDescription) { validateCollation(connectionDescription, collation); BsonDocument commandDocument = new BsonDocument("findAndModify", new BsonString(getNamespace().getCollectionName())); putIfNotNull(commandDocument, "query", getFilter()); putIfNotNull(commandDocument, "fields", getProjection()); putIfNotNull(commandDocument, "sort", getSort()); putIfNotZero(commandDocument, "maxTimeMS", getMaxTime(MILLISECONDS)); commandDocument.put("remove", BsonBoolean.TRUE); addWriteConcernToCommand(connectionDescription, commandDocument, sessionContext); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } addTxnNumberToCommand(serverDescription, connectionDescription, commandDocument, sessionContext); return commandDocument; } };
FindAndDeleteOperation<TDocument> findOneAndDelete(final Bson filter, final FindOneAndDeleteOptions options) { return new FindAndDeleteOperation<TDocument>(namespace, writeConcern, retryWrites, getCodec()) .filter(toBsonDocument(filter)) .projection(toBsonDocument(options.getProjection())) .sort(toBsonDocument(options.getSort())) .maxTime(options.getMaxTime(MILLISECONDS), MILLISECONDS) .collation(options.getCollation()); }
WriteOperation<DBObject> operation; if (options.isRemove()) { operation = new FindAndDeleteOperation<DBObject>(getNamespace(), writeConcern, retryWrites, objectCodec) .filter(wrapAllowNull(query)) .projection(wrapAllowNull(options.getProjection())) .sort(wrapAllowNull(options.getSort())) .maxTime(options.getMaxTime(MILLISECONDS), MILLISECONDS) .collation(options.getCollation()); } else { DBObject update = options.getUpdate();