From ee4c698e03145b6cad2ed916b1b9249f910845cd Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 30 Oct 2015 21:14:02 +0100 Subject: core: o Using manyOrNone on SELECTs that can return an empty result set. --- src/DillerDao.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DillerDao.js b/src/DillerDao.js index 3a6601f..cae80d7 100644 --- a/src/DillerDao.js +++ b/src/DillerDao.js @@ -9,11 +9,11 @@ function DillerDao(tx) { // ------------------------------------------------------------------------------------------------------------------- function devices() { - return tx.many("SELECT " + deviceColumns + " FROM device"); + return tx.manyOrNone("SELECT " + deviceColumns + " FROM device"); } function deviceById(id) { - return tx.oneOrNone("SELECT " + deviceColumns + " FROM device WHERE id=$1", id); + return tx.one("SELECT " + deviceColumns + " FROM device WHERE id=$1", id); } function deviceByKey(key) { @@ -37,7 +37,7 @@ function DillerDao(tx) { } function devicePropertiesByDeviceId(deviceId) { - return tx.many('SELECT ' + propertyColumns + ' FROM device_property WHERE device=$1', [deviceId]); + return tx.manyOrNone('SELECT ' + propertyColumns + ' FROM device_property WHERE device=$1', [deviceId]); } function insertDeviceProperty(deviceId, key) { @@ -58,7 +58,7 @@ function DillerDao(tx) { function valuesByPropertyId(propertyId, limit) { limit = limit || 10; - return tx.many('SELECT timestamp, coalesce(value_numeric::text, value_text) AS value FROM value WHERE property=$1 ORDER BY timestamp DESC LIMIT $2', [propertyId, limit]); + return tx.manyOrNone('SELECT timestamp, coalesce(value_numeric::text, value_text) AS value FROM value WHERE property=$1 ORDER BY timestamp DESC LIMIT $2', [propertyId, limit]); } function insertValue(propertyId, value) { -- cgit v1.2.3