exports.allProbes = function() {
var rows = db.all("SELECT * FROM probes;");
return rows;
};
main:
var json_values = allProbes();
Is it possible to do something like that? I mean, without using a callback function: just, read data (sync mode) from the db. and return a json formatted output?
Thanks.
You will not be able to do that with sqlite3. With sqlite3 module the only available mode of operation is asynchronous execution, and you will have to use a callback. Eg.
exports.allProbes = function(callback) {
db.all("SELECT * FROM probes;", function(err, all) {
callback(err, all);
});
};
Then in your code:
var json_values;
allProbes(function(err, all) {
json_values = all;
});
Check sqlite3 API Docs.