Skip to content

Commit ea085ec

Browse files
committed
Merge branch 'pr/125'
Change-Id: I570e53e4bf714877e4f2d8e831d6f876c98d312d
2 parents 7be3b22 + 5facd95 commit ea085ec

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

mongo/collection.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ func (coll *Collection) updateOrReplaceOne(ctx context.Context, filter,
509509
res := &UpdateResult{
510510
MatchedCount: r.MatchedCount,
511511
ModifiedCount: r.ModifiedCount,
512+
UpsertedCount: int64(len(r.Upserted)),
512513
}
513514
if len(r.Upserted) > 0 {
514515
res.UpsertedID = r.Upserted[0].ID
@@ -620,6 +621,7 @@ func (coll *Collection) UpdateMany(ctx context.Context, filter interface{}, upda
620621
res := &UpdateResult{
621622
MatchedCount: r.MatchedCount,
622623
ModifiedCount: r.ModifiedCount,
624+
UpsertedCount: int64(len(r.Upserted)),
623625
}
624626
// TODO(skriptble): Is this correct? Do we only return the first upserted ID for an UpdateMany?
625627
if len(r.Upserted) > 0 {

mongo/results.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ type UpdateResult struct {
7878
MatchedCount int64
7979
// The number of documents that were modified.
8080
ModifiedCount int64
81+
// The number of documents that were upserted.
82+
UpsertedCount int64
8183
// The identifier of the inserted document if an upsert took place.
8284
UpsertedID interface{}
8385
}

0 commit comments

Comments
 (0)