My front end is all Meteor however do the nature of the data, I use a PostgreSQL to store the majority of the bulk of it so I need the server to query and work with the responses.
I am using the npm package pg (https://node-postgres.com) and have been trying to get some functions to query and return but overall, it seems I am running into Meteor not waiting for promises to resolve.
I have tried it with call backs and also wrapping it different ways but I am still getting undefined and trying to see if there is a different way I should be doing this in Meteor. Below is a quick summary is what I am trying to do. I have a function that relies on some queries so when they resolve, I want to then continue on with the function on the server.
serverUpdate = function()
{
var lastReading = findLastTimestamp()
if(lastReading.....)
// Continues on here working with the timestamp
}
findLastTimestamp = function() {
pool.query("SELECT time FROM sensor_data ORDER BY time DESC LIMIT 1", Meteor.bindEnvironment(function(error, result)
{
return result
}));
}