From fb32fd96f777ac8fd3c5438446599bf50097d6a0 Mon Sep 17 00:00:00 2001 From: Daniel Wylie Date: Tue, 7 Oct 2014 13:54:56 +1300 Subject: [PATCH] Merge into engines expected format --- lib/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 188eac0..200a055 100644 --- a/lib/index.js +++ b/lib/index.js @@ -36,7 +36,23 @@ engine.getData = function (startDate, endDate, callback) { } }, {$sort: {"_id.year": 1, "_id.month": 1, "_id.day": 1}} - ], callback); + ], function (err, data) { + if (err) { + callback(err); + return; + } + + var result = []; + for (var i = 0; i < data.length; i++) { + var d = data[i]; + result.push({ + date: new Date(d._id.year, d._id.month, d._id.day), + value: d.hits + }); + } + + callback(null, result); + }); }; module.exports = engine; \ No newline at end of file