Skip to content

Commit 90772bf

Browse files
feat(api): remove unnecessary write concern from DeviceSetOnline
1 parent 2f64c59 commit 90772bf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

api/store/mongo/device.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"go.mongodb.org/mongo-driver/bson"
1818
"go.mongodb.org/mongo-driver/mongo"
1919
"go.mongodb.org/mongo-driver/mongo/options"
20-
"go.mongodb.org/mongo-driver/mongo/writeconcern"
2120
)
2221

2322
// DeviceList returns a list of devices based on the given filters, pagination and sorting.
@@ -332,10 +331,9 @@ func (s *Store) DeviceSetOnline(ctx context.Context, uid models.UID, timestamp t
332331
return FromMongoError(err)
333332
}
334333

335-
collOptions := writeconcern.W1()
336334
updateOptions := options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.Before)
337335

338-
result := s.db.Collection("devices", options.Collection().SetWriteConcern(collOptions)).
336+
result := s.db.Collection("devices").
339337
FindOneAndUpdate(ctx, bson.M{"uid": uid},
340338
mongo.Pipeline{
341339
bson.D{
@@ -361,7 +359,7 @@ func (s *Store) DeviceSetOnline(ctx context.Context, uid models.UID, timestamp t
361359
updated := cd.LastSeen.Before(timestamp)
362360
if updated {
363361
replaceOptions := options.Replace().SetUpsert(true)
364-
_, err := s.db.Collection("connected_devices", options.Collection().SetWriteConcern(collOptions)).
362+
_, err := s.db.Collection("connected_devices").
365363
ReplaceOne(ctx, bson.M{"uid": uid}, &cd, replaceOptions)
366364
if err != nil {
367365
return FromMongoError(err)

0 commit comments

Comments
 (0)