class Mongo::Operation::Write::Bulk::Insert::LegacyResult
Defines custom behaviour of results when inserting. For server versions < 2.5.5 (that don't use write commands).
@since 2.0.0
Attributes
inserted_ids[R]
Get the ids of the inserted documents.
@since 2.0.0
Public Class Methods
new(replies, ids)
click to toggle source
Initialize a new result.
@example Instantiate the result.
Result.new(replies, inserted_ids)
@param [ Protocol::Message ] replies The wire protocol replies. @param [ Array<Object> ] ids The ids of the inserted documents.
@since 2.0.0
# File lib/mongo/operation/write/bulk/insert/result.rb, line 92 def initialize(replies, ids) @replies = [ *replies ] if replies @inserted_ids = ids end
Public Instance Methods
inserted_id()
click to toggle source
Gets the id of the document inserted.
@example Get id of the document inserted.
result.inserted_id
@return [ Object ] The id of the document inserted.
@since 2.0.0
# File lib/mongo/operation/write/bulk/insert/result.rb, line 121 def inserted_id inserted_ids.first end
n_inserted()
click to toggle source
Gets the number of documents inserted.
@example Get the number of documents inserted.
result.n_inserted
@return [ Integer ] The number of documents inserted.
@since 2.0.0
# File lib/mongo/operation/write/bulk/insert/result.rb, line 105 def n_inserted return 0 unless acknowledged? @replies.reduce(0) do |n, reply| n += 1 unless reply_write_errors?(reply) n end end