From afed849a57bb0877dbba1aab2f78a4c6ad131174 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 7 Oct 2021 12:44:09 +0200 Subject: [PATCH] Update commandRegistryMongoDB.js --- lib/services/commands/commandRegistryMongoDB.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/commands/commandRegistryMongoDB.js b/lib/services/commands/commandRegistryMongoDB.js index 31efedc3a..85c8ac149 100644 --- a/lib/services/commands/commandRegistryMongoDB.js +++ b/lib/services/commands/commandRegistryMongoDB.js @@ -41,7 +41,7 @@ function findCommand(service, subservice, deviceId, name, callback) { logger.debug(context, 'Looking for command [%s] for device [%s]', name, deviceId); - const query = Command.model.findOne(queryObj); + const query = Command.model.findOne(queryObj, null, { sort: { creationDate: -1 } }); query.select({ __v: 0 });