Skip to content

Commit

Permalink
Merge pull request #371 from tranchitella/me-50
Browse files Browse the repository at this point in the history
fix: update_ts field when searching devices and selecting attributes
  • Loading branch information
tranchitella committed Jan 30, 2023
2 parents b1b2f59 + 7ad8920 commit 6ba2aa0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2022 Northern.tech AS
Copyright 2023 Northern.tech AS

All content in this project is licensed under the Apache License v2, unless
indicated otherwise.
Expand Down
2 changes: 1 addition & 1 deletion LIC_FILES_CHKSUM.sha256
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# These are identical to Apache-2.0 license.
c773be5f6ca136ca7791e117829ff9a60b4a1436cc2bfa9214895f4ed9b3f2a9 COPYING
1033348db7606a7e61b6484f293847cf8d7a35766efebb97e304d4bd5d7f3f6b LICENSE
52b2497ce07650b825015e80ca7a5d40c360c04c530234ca6d950b0f98bca23a LICENSE
a4e99d13c6cd0e4faf3867ae5c9815ff88cab3cefdefe0dc1ec9ac28b1152944 vendor/github.com/mendersoftware/go-lib-micro/LICENSE
5e3400b93bbb099e83e52bab885e7441750673c21f97988ca3f1240639b63283 vendor/github.com/spf13/afero/LICENSE.txt
f6918bd93ffe07f4b2c61b8287c32cb3122e08aed0be50f1c7d0eddc87877a8f vendor/gopkg.in/ini.v1/LICENSE
Expand Down
12 changes: 9 additions & 3 deletions store/mongo/datastore_mongo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Northern.tech AS
// Copyright 2023 Northern.tech AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -100,7 +100,7 @@ func NewDataStoreMongoWithSession(client *mongo.Client) store.DataStore {
return &DataStoreMongo{client: client}
}

//config.ConnectionString must contain a valid
// config.ConnectionString must contain a valid
func NewDataStoreMongo(config DataStoreMongoConfig) (store.DataStore, error) {
//init master session
var err error
Expand Down Expand Up @@ -1133,7 +1133,13 @@ func (db *DataStoreMongo) SearchDevices(
findOptions.SetLimit(int64(searchParams.PerPage))

if len(searchParams.Attributes) > 0 {
projection := bson.M{DbDevUpdatedTs: 1}
name := fmt.Sprintf(
"%s-%s",
model.AttrScopeSystem,
model.GetDeviceAttributeNameReplacer().Replace(DbDevUpdatedTs),
)
field := fmt.Sprintf("%s.%s", DbDevAttributes, name)
projection := bson.M{field: 1}
for _, attribute := range searchParams.Attributes {
name := fmt.Sprintf(
"%s-%s",
Expand Down

0 comments on commit 6ba2aa0

Please sign in to comment.