class Mongo::Operation::Insert::Result
Defines custom behavior of results for an insert.
According to the CRUD spec, reporting the inserted ids is optional. It can be added to this class later, if needed.
@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 [ Array<Protocol::Message> | nil ] replies The wire protocol replies, if any. @param [ Array<Object> ] ids The ids of the inserted documents.
@since 2.0.0
# File lib/mongo/operation/insert/result.rb, line 41 def initialize(replies, ids) @replies = [*replies] if replies @inserted_ids = ids end
Public Instance Methods
bulk_result()
click to toggle source
# File lib/mongo/operation/insert/result.rb, line 58 def bulk_result BulkResult.new(@replies, @inserted_ids) end
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/insert/result.rb, line 54 def inserted_id inserted_ids.first end