node-persist icon indicating copy to clipboard operation
node-persist copied to clipboard

Query results are udefined

Open RobertZito opened this issue 11 years ago • 1 comments

Does this make sense, I am attempting to get the deptname from dept, the trace looks right with SELECT count(*) as count FROM depts t0 WHERE t0.groupname = :1 [ 'warehouse' ], when I run this direct in sql developer I get the right results but if I log console.log(count) I get undefined. Am I returning the results properly?

var persist = require("persist"); var type = persist.type;

dept = persist.define('ALERT', { 'id': type.INTEGER, 'deptname': type.STRING });

persist.connect({ "driver": "oracle", "hostname": "127.0.0.1", "database": "hr", "user": "user", "password": "password", trace: true },

function(err, connection) {
    alert.where('deptname = ?', 'warehouse').count(connection, function(err, count) {

        console.log(count);
    });
});

RobertZito avatar Mar 16 '14 18:03 RobertZito

Try adding this in your count callback:

if(err) console.log(err)

To ensure you don't have a hidden error happening (you should probably do that for your connection callback as well - it has helped me immensely while trying to use this library

ioneyed avatar Mar 31 '14 19:03 ioneyed