Search in sources :

Example 1 with InsertOperation

use of com.mongodb.internal.operation.InsertOperation in project mongo-java-driver by mongodb.

the class CollectionHelper method insertDocuments.

public void insertDocuments(final List<BsonDocument> documents, final WriteConcern writeConcern, final WriteBinding binding) {
    List<InsertRequest> insertRequests = new ArrayList<InsertRequest>(documents.size());
    for (BsonDocument document : documents) {
        insertRequests.add(new InsertRequest(document));
    }
    new InsertOperation(namespace, true, writeConcern, false, insertRequests).execute(binding);
}
Also used : BsonDocument(org.bson.BsonDocument) InsertOperation(com.mongodb.internal.operation.InsertOperation) InsertRequest(com.mongodb.internal.bulk.InsertRequest) ArrayList(java.util.ArrayList)

Aggregations

InsertRequest (com.mongodb.internal.bulk.InsertRequest)1 InsertOperation (com.mongodb.internal.operation.InsertOperation)1 ArrayList (java.util.ArrayList)1 BsonDocument (org.bson.BsonDocument)1