All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mongodb.internal.operation.SyncOperations Maven / Gradle / Ivy

Go to download

The Java operations layer for the MongoDB Java Driver. Third parties can ' + 'wrap this layer to provide custom higher-level APIs

There is a newer version: 5.1.4
Show newest version
/*
 * Copyright 2008-present MongoDB, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mongodb.internal.operation;

import com.mongodb.MongoNamespace;
import com.mongodb.ReadPreference;
import com.mongodb.WriteConcern;
import com.mongodb.bulk.BulkWriteResult;
import com.mongodb.client.model.BulkWriteOptions;
import com.mongodb.client.model.Collation;
import com.mongodb.client.model.CountOptions;
import com.mongodb.internal.client.model.CountStrategy;
import com.mongodb.client.model.CreateIndexOptions;
import com.mongodb.client.model.DeleteOptions;
import com.mongodb.client.model.DropIndexOptions;
import com.mongodb.client.model.FindOneAndDeleteOptions;
import com.mongodb.client.model.FindOneAndReplaceOptions;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.FindOptions;
import com.mongodb.client.model.IndexModel;
import com.mongodb.client.model.InsertManyOptions;
import com.mongodb.client.model.InsertOneOptions;
import com.mongodb.client.model.MapReduceAction;
import com.mongodb.client.model.RenameCollectionOptions;
import com.mongodb.client.model.ReplaceOptions;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.model.WriteModel;
import com.mongodb.operation.BatchCursor;
import com.mongodb.operation.MapReduceBatchCursor;
import com.mongodb.operation.MapReduceStatistics;
import com.mongodb.operation.ReadOperation;
import com.mongodb.operation.WriteOperation;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.conversions.Bson;

import java.util.List;

/**
 * This class is NOT part of the public API. It may change at any time without notification.
 */
public final class SyncOperations {
    private final Operations operations;

    public SyncOperations(final Class documentClass, final ReadPreference readPreference,
                          final CodecRegistry codecRegistry) {
        this(null, documentClass, readPreference, codecRegistry, WriteConcern.ACKNOWLEDGED, false);
    }

    public SyncOperations(final MongoNamespace namespace, final Class documentClass, final ReadPreference readPreference,
                          final CodecRegistry codecRegistry) {
        this(namespace, documentClass, readPreference, codecRegistry, WriteConcern.ACKNOWLEDGED, false);
    }

    public SyncOperations(final MongoNamespace namespace, final Class documentClass, final ReadPreference readPreference,
                          final CodecRegistry codecRegistry, final WriteConcern writeConcern, final boolean retryWrites) {
        this.operations = new Operations(namespace, documentClass, readPreference, codecRegistry, writeConcern, retryWrites);
    }

    public ReadOperation count(final Bson filter, final CountOptions options, final CountStrategy countStrategy) {
        return operations.count(filter, options, countStrategy);
    }

    public  ReadOperation> findFirst(final Bson filter, final Class resultClass,
                                                                   final FindOptions options) {
        return operations.findFirst(filter, resultClass, options);
    }

    public  ReadOperation> find(final Bson filter, final Class resultClass,
                                                              final FindOptions options) {
        return operations.find(filter, resultClass, options);
    }

    public  ReadOperation> find(final MongoNamespace findNamespace, final Bson filter,
                                                              final Class resultClass, final FindOptions options) {
        return operations.find(findNamespace, filter, resultClass, options);
    }

    public  ReadOperation> distinct(final String fieldName, final Bson filter,
                                                                  final Class resultClass, final long maxTimeMS,
                                                                  final Collation collation) {
        return operations.distinct(fieldName, filter, resultClass, maxTimeMS, collation);
    }

    public  ReadOperation> aggregate(final List pipeline, final Class resultClass,
                                                                   final long maxTimeMS, final long maxAwaitTimeMS, final Integer batchSize,
                                                                   final Collation collation, final Bson hint, final String comment,
                                                                   final Boolean allowDiskUse, final Boolean useCursor) {
        return operations.aggregate(pipeline, resultClass, maxTimeMS, maxAwaitTimeMS, batchSize, collation, hint, comment, allowDiskUse,
                useCursor);
    }

    public WriteOperation aggregateToCollection(final List pipeline, final long maxTimeMS,
                                                      final Boolean allowDiskUse, final Boolean bypassDocumentValidation,
                                                      final Collation collation, final Bson hint, final String comment) {
        return operations.aggregateToCollection(pipeline, maxTimeMS, allowDiskUse, bypassDocumentValidation, collation, hint, comment);
    }

    public WriteOperation mapReduceToCollection(final String databaseName, final String collectionName,
                                                                     final String mapFunction, final String reduceFunction,
                                                                     final String finalizeFunction, final Bson filter, final int limit,
                                                                     final long maxTimeMS, final boolean jsMode, final Bson scope,
                                                                     final Bson sort, final boolean verbose, final MapReduceAction action,
                                                                     final boolean nonAtomic, final boolean sharded,
                                                                     final Boolean bypassDocumentValidation, final Collation collation) {
        return operations.mapReduceToCollection(databaseName, collectionName, mapFunction, reduceFunction, finalizeFunction, filter, limit,
                maxTimeMS, jsMode, scope, sort, verbose, action, nonAtomic, sharded, bypassDocumentValidation, collation);
    }

    public  ReadOperation> mapReduce(final String mapFunction, final String reduceFunction,
                                                                            final String finalizeFunction, final Class resultClass,
                                                                            final Bson filter, final int limit,
                                                                            final long maxTimeMS, final boolean jsMode, final Bson scope,
                                                                            final Bson sort, final boolean verbose,
                                                                            final Collation collation) {
        return operations.mapReduce(mapFunction, reduceFunction, finalizeFunction, resultClass, filter, limit, maxTimeMS, jsMode, scope,
                sort, verbose, collation);
    }

    public WriteOperation findOneAndDelete(final Bson filter, final FindOneAndDeleteOptions options) {
        return operations.findOneAndDelete(filter, options);
    }

    public WriteOperation findOneAndReplace(final Bson filter, final TDocument replacement,
                                                       final FindOneAndReplaceOptions options) {
        return operations.findOneAndReplace(filter, replacement, options);
    }

    public WriteOperation findOneAndUpdate(final Bson filter, final Bson update, final FindOneAndUpdateOptions options) {
        return operations.findOneAndUpdate(filter, update, options);
    }

    public WriteOperation insertOne(final TDocument document, final InsertOneOptions options) {
        return operations.insertOne(document, options);
    }


    public WriteOperation replaceOne(final Bson filter, final TDocument replacement, final ReplaceOptions options) {
        return operations.replaceOne(filter, replacement, options);
    }

    public WriteOperation deleteOne(final Bson filter, final DeleteOptions options) {
        return operations.deleteOne(filter, options);
    }

    public WriteOperation deleteMany(final Bson filter, final DeleteOptions options) {
        return operations.deleteMany(filter, options);
    }

    public WriteOperation updateOne(final Bson filter, final Bson update, final UpdateOptions updateOptions) {
        return operations.updateOne(filter, update, updateOptions);
    }

    public WriteOperation updateMany(final Bson filter, final Bson update, final UpdateOptions updateOptions) {
        return operations.updateMany(filter, update, updateOptions);
    }

    public WriteOperation insertMany(final List documents,
                                                      final InsertManyOptions options) {
        return operations.insertMany(documents, options);
    }

    @SuppressWarnings("unchecked")
    public WriteOperation bulkWrite(final List> requests,
                                                     final BulkWriteOptions options) {
        return operations.bulkWrite(requests, options);
    }


    public WriteOperation dropCollection() {
        return operations.dropCollection();
    }

    public WriteOperation renameCollection(final MongoNamespace newCollectionNamespace,
                                                 final RenameCollectionOptions options) {
        return operations.renameCollection(newCollectionNamespace, options);
    }

    public WriteOperation createIndexes(final List indexes, final CreateIndexOptions options) {
        return operations.createIndexes(indexes, options);
    }

    public WriteOperation dropIndex(final String indexName, final DropIndexOptions options) {
        return operations.dropIndex(indexName, options);
    }

    public WriteOperation dropIndex(final Bson keys, final DropIndexOptions options) {
        return operations.dropIndex(keys, options);
    }

    public  ReadOperation> listCollections(final String databaseName, final Class resultClass,
                                                                         final Bson filter, final boolean collectionNamesOnly,
                                                                         final Integer batchSize, final long maxTimeMS) {
        return operations.listCollections(databaseName, resultClass, filter, collectionNamesOnly, batchSize, maxTimeMS);
    }

    public  ReadOperation> listDatabases(final Class resultClass, final Bson filter,
                                                                       final Boolean nameOnly, final long maxTimeMS) {
        return operations.listDatabases(resultClass, filter, nameOnly, maxTimeMS);
    }

    public  ReadOperation> listIndexes(final Class resultClass, final Integer batchSize,
                                                                     final long maxTimeMS) {
        return operations.listIndexes(resultClass, batchSize, maxTimeMS);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy