1

I'm trying to get "Prepared Statement Example" working ( http://sailsjs.org/documentation/reference/waterline-orm/models/query ) but I only get "Error: ER_EMPTY_QUERY: Query was empty"

Here's what I have tried:

day: function(req, res, next) {
  Lampo1.query({
    text: 'SELECT id FROM lampo WHERE node = $1',
    values: [ "node1" ]
  }, function(err, lampo1) {
    if (err) return res.serverError(err);
    return res.json(lampo1);
  });
},

So I try to make query and add values as parameter, but seems like it won't generate the query at all. Basic example query from the link above works.

Yann Bertrand
  • 3,084
  • 1
  • 22
  • 38
artturi
  • 11
  • 3

1 Answers1

0

Found answer from How to use Model.query() with promises in SailsJS/Waterline?

day: function(req, res, next) {
var Promise = require('bluebird');
Lampo1.query("SELECT node FROM lampo1 WHERE id = ?", [ 15 ])
var dayQueryAsync = Promise.promisify(Lampo1.query);
dayQueryAsync("SELECT lampo FROM lampo1 WHERE id = ?", [ 15 ])
.then(function(lampo) {
console.log(lampo);
return res.json(lampo);
});
Community
  • 1
  • 1
artturi
  • 11
  • 3