aboutsummaryrefslogtreecommitdiff
path: root/src/DillerDao.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/DillerDao.js')
-rw-r--r--src/DillerDao.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/DillerDao.js b/src/DillerDao.js
index c4d0e67..b46e734 100644
--- a/src/DillerDao.js
+++ b/src/DillerDao.js
@@ -33,7 +33,7 @@ function DillerDao(tx) {
}
function devicePropertyByDeviceIdAndKey(deviceId, key) {
- return tx.oneOrNone('SELECT id FROM device_property WHERE device=$1 AND key=$2', [deviceId, key]);
+ return tx.oneOrNone('SELECT ' + propertyColumns + ' FROM device_property WHERE device=$1 AND key=$2', [deviceId, key]);
}
function devicePropertiesByDeviceId(deviceId) {
@@ -41,11 +41,11 @@ function DillerDao(tx) {
}
function insertDeviceProperty(deviceId, key) {
- return tx.oneOrNone('INSERT INTO device_property(id, device, key, created_timestamp) VALUES(DEFAULT, $1, $2, CURRENT_TIMESTAMP) RETURNING ' + propertyColumns, [deviceId, key]);
+ return tx.one('INSERT INTO device_property(id, device, key, created_timestamp) VALUES(DEFAULT, $1, $2, CURRENT_TIMESTAMP) RETURNING ' + propertyColumns, [deviceId, key]);
}
function updatePropertyName(id, name) {
- return tx.none('UPDATE device_property SET name=$1 WHERE id=$2', name, id);
+ return tx.none('UPDATE device_property SET name=$1 WHERE id=$2', [name, id]);
}
function updatePropertyDescription(id, description) {
@@ -58,7 +58,7 @@ function DillerDao(tx) {
function valuesByPropertyId(propertyId, limit) {
limit = limit || 10;
- return tx.many('SELECT timestamp, value FROM value WHERE property=$1 LIMIT $2', [propertyId, limit]);
+ return tx.many('SELECT timestamp, value FROM value WHERE property=$1 ORDER BY timestamp DESC LIMIT $2', [propertyId, limit]);
}
function insertValue(propertyId, value) {