From 1da11bf59471748eb8e56312cc0bf823df4d68bb Mon Sep 17 00:00:00 2001 From: "Ethan.Z" Date: Thu, 21 Nov 2024 15:16:45 -0500 Subject: [PATCH] add parallel promises --- src-electron/rest/user-data.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src-electron/rest/user-data.js b/src-electron/rest/user-data.js index d3015fde82..6fa1174ed3 100644 --- a/src-electron/rest/user-data.js +++ b/src-electron/rest/user-data.js @@ -111,25 +111,23 @@ async function getEndpointTypeElements( endpointTypeClusterId, deviceTypeClusterId ) { - let elements = {} - elements.attributes = - await queryAttribute.selectAttributesByEndpointTypeClusterId( + let [attributes, commands, events] = await Promise.all([ + queryAttribute.selectAttributesByEndpointTypeClusterId( db, endpointTypeClusterId - ) - elements.commands = - await queryCommand.selectCommandsByEndpointTypeClusterIdAndDeviceTypeClusterId( + ), + queryCommand.selectCommandsByEndpointTypeClusterIdAndDeviceTypeClusterId( db, endpointTypeClusterId, deviceTypeClusterId - ) - elements.events = - await queryEvent.selectEventsByEndpointTypeClusterIdAndDeviceTypeClusterId( + ), + queryEvent.selectEventsByEndpointTypeClusterIdAndDeviceTypeClusterId( db, endpointTypeClusterId, deviceTypeClusterId ) - return elements + ]) + return { attributes, commands, events } } /**