Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/MongoDB/InsertManyResult.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ The number of documents inserted.
=cut

has inserted_count => (
is => 'ro',
default => 0,
is => 'lazy',
builder => '_build_inserted_count',
isa => Num,
);

sub _build_inserted_count
{
my ($self) = @_;
return scalar @{ $self->inserted };
}

=attr inserted

An array reference containing information about inserted documents (if any).
Expand Down
1 change: 1 addition & 0 deletions t/crud.t
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ subtest "insert_many" => sub {
},
"inserted_ids contains correct keys/values"
);
is($res->inserted_count, 2, "Two docs inserted.");

# ordered insert should halt on error
$coll->drop;
Expand Down