From 85474565b0a0d92a09fecb14e8bc0afaad7fbc64 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 1 Nov 2015 15:28:40 +0100 Subject: misc: o Playing around with type annotations. --- src/DillerDao.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/DillerDao.js') diff --git a/src/DillerDao.js b/src/DillerDao.js index 63ad3c1..d81b418 100644 --- a/src/DillerDao.js +++ b/src/DillerDao.js @@ -1,15 +1,21 @@ var _ = require('lodash'); +/** + * @param tx {PgTx} + * @class + */ function DillerDao(tx) { var deviceColumns = 'id, created_timestamp, key, name, description'; var propertyColumns = 'id, created_timestamp, device, key, name, description, last_value, last_timestamp'; - var valueColumns = 'property, timestamp, value_text, value_numeric'; // ------------------------------------------------------------------------------------------------------------------- // Device // ------------------------------------------------------------------------------------------------------------------- + /** + * @returns {Promise} + */ function devices() { return tx.manyOrNone("SELECT " + deviceColumns + " FROM device"); } @@ -122,6 +128,9 @@ function DillerDao(tx) { }); } + /** + * @returns {Promise} + */ function updateMinuteAggregatesForProperty(propertyId, timestamp) { return tx.none('DELETE FROM value_by_minute WHERE property=$1 AND timestamp=DATE_TRUNC(\'minute\', $2::TIMESTAMPTZ)', [propertyId, timestamp]) .then(function () { @@ -134,6 +143,7 @@ function DillerDao(tx) { }); } + /** @lends DillerDao.prototype */ return { devices: devices, deviceById: deviceById, @@ -151,7 +161,14 @@ function DillerDao(tx) { insertValue: insertValue, updateHourAggregatesForProperty: updateHourAggregatesForProperty, updateMinuteAggregatesForProperty: updateMinuteAggregatesForProperty - } + }; } +/** + * @type DillerDao + */ +var x; + +x.deviceById(123) + module.exports = DillerDao; -- cgit v1.2.3