From bba90cb29703814791965576d1859806a310b698 Mon Sep 17 00:00:00 2001 From: Alvaro Vega <alvaro.vegagarcia@telefonica.com> Date: Wed, 11 Dec 2024 18:48:06 +0100 Subject: [PATCH] query with lean to ensure simple pojos --- lib/services/devices/deviceRegistryMongoDB.js | 4 ++-- .../ngsiv2/lazyAndCommands/polling-commands-test.js | 13 +------------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/services/devices/deviceRegistryMongoDB.js b/lib/services/devices/deviceRegistryMongoDB.js index bf66230c7..4086f1933 100644 --- a/lib/services/devices/deviceRegistryMongoDB.js +++ b/lib/services/devices/deviceRegistryMongoDB.js @@ -266,7 +266,7 @@ function getByNameAndType(name, type, service, servicepath, callback) { const query = Device.model.findOne(optionsQuery); query.select({ __v: 0 }); - + query.lean(); query .exec({}) .then((data) => { @@ -375,7 +375,7 @@ function getDevicesByAttribute(name, value, service, subservice, callback) { const query = Device.model.find(filter); query.select({ __v: 0 }); - + query.lean(); query .exec({}) .then((devices) => { diff --git a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js index 2c021caf4..c3c2f2d4a 100644 --- a/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +++ b/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js @@ -342,17 +342,6 @@ describe('NGSI-v2 - Polling commands', function () { }; beforeEach(function (done) { - // statusAttributeMock = nock('http://192.168.1.1:1026') - // .matchHeader('fiware-service', 'smartgondor') - // .matchHeader('fiware-servicepath', 'gardens') - // .post( - // '/v2/entities?options=upsert', - // //utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json') - // utils.readExampleFile( - // './test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json' ) - // ) - // .reply(204); - statusAttributeMock = nock('http://192.168.1.1:1026') .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', 'gardens') @@ -393,7 +382,7 @@ describe('NGSI-v2 - Polling commands', function () { request(options, function (error, response, body) { setTimeout(function () { iotAgentLib.commandQueue('smartgondor', 'gardens', 'r2d2', function (error, listCommands) { - //statusAttributeMock.done(); + statusAttributeMock.done(); done(); }); }, 300);