aboutsummaryrefslogtreecommitdiff
path: root/src/DillerDao.js
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-10-25 00:33:41 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-10-25 01:47:52 +0200
commite8ec4001ce1297d5a3db6d3fc8af8de47daa6a61 (patch)
tree839d9c1da0c2b1db539c104d9aacc8c8e62a3dcd /src/DillerDao.js
parent0266bdd60cb9cccf20a5ded3eba72ea833bee72d (diff)
downloaddiller-server-e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61.tar.gz
diller-server-e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61.tar.bz2
diller-server-e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61.tar.xz
diller-server-e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61.zip
wip
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) {