How do I get the number of rows from a table?

1115 views node.js

I am simply trying to get the number of rows in a table to update a counter. I've tried:

getRowCount(callback) {
    this.db.all(`SELECT COUNT(*) FROM pk_patients`, (err, rows) => {
        if (err) {
        } else {

I just get undefined. The table does have data in it.

answered question

1 Answer


Change SELECT COUNT(*) FROM pk_patients

to SELECT COUNT(*) as 'count' FROM pk_patients

posted this

Have an answer?


Please login first before posting an answer.