0

I have something like this:

      var sql = "SELECT EXISTS(SELECT * FROM files)";

      var query = db.query(sql, function(err, result) {
        console.log(result[0]);
      });

console.log returns: RowDataPacket { 'EXISTS(SELECT * FROM files)': 1 }

Looks like this is a key-value pair? how do i access the value in this case?

I did come across this: How to access a RowDataPacket object. but in my case since the property is a string I am not sure how to access it.

ssn
  • 2,631
  • 4
  • 24
  • 28
  • I did come across that, but i am not sure what the user_id they refer to is!? i dont see it in my logs. Please educate me if this stupid. – ssn Apr 09 '20 at 23:29
  • In that question, it's a property of the object. Here, `EXISTS(SELECT * FROM files)` is a property of your object. Do the same thing. – CertainPerformance Apr 09 '20 at 23:30
  • there the supposed answer is to do results[0].user_id. but in my case the property is a string. how can i use this? – ssn Apr 09 '20 at 23:39

0 Answers0