-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I'm trying to use external moment.js lib without luck. Here is my code:
CREATE FUNCTION getWeek AS
``
function(x) {
let moment = global.get('moment');
return moment(x).week();
}
``;
SELECT
COUNT(*),
SUBSTRING(created_at,1,10) AS created_at,
getWeek(created_at)
FROM ?
GROUP BY SUBSTRING(created_at,1,10)
I failed also when tried to acceess msg object. Is there a way to resolve it?
EDITED:
As a workaround I used moment in function node before using alasql node so I can work with "ready" data.
let moment = global.get('moment');
for (let i = 0; i < msg.payload.length; i++) {
msg.payload[i].week = moment(msg.payload[i].created_at).week(),
msg.payload[i].month = moment(msg.payload[i].created_at).month(),
msg.payload[i].yaer = moment(msg.payload[i].created_at).year()
}
return msg;
Metadata
Metadata
Assignees
Labels
No labels