Sha256: 26cd67dddd54212ca4773cf299c9b6fdf23211a8618265590975d8c35085d3f6
Contents?: true
Size: 1.49 KB
Versions: 6
Compression:
Stored size: 1.49 KB
Contents
# Copyright (C) 2014-2015 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. module Mongo module BulkWrite # Defines behavior for validating and combining insert bulk write operations. # # @since 2.0.0. module Insertable private def valid_doc?(doc) doc.respond_to?(:keys) end def validate_insert_ops!(type, inserts) if inserts.empty? raise Error::InvalidBulkOperation.new(type, inserts) end inserts.each do |i| unless valid_doc?(i) raise Error::InvalidBulkOperation.new(type, i) end end end def insert_one(op, server) validate_insert_ops!(__method__, op[:insert_one]) Operation::Write::BulkInsert.new( :documents => op[:insert_one].flatten, :db_name => database.name, :coll_name => @collection.name, :write_concern => write_concern, :ordered => ordered? ).execute(server.context) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems