diff --git a/db.js b/db.js index 0d85eb3..08d2517 100644 --- a/db.js +++ b/db.js @@ -222,6 +222,24 @@ class DB { }; } + async getMaxIdx(tblName) { + const params = []; + let sql = 'SELECT max(idx) AS max_idx FROM `' + tblName + '` '; + + const {err, row} = await this.execQueryOne(sql, params); + if (err) { + return { + 'err': err, + 'maxIdx': BigInt(0) + }; + } else { + return { + 'err': err, + 'maxIdx': row && row['max_idx'] != null ? BigInt(row['max_idx']) : BigInt(0) + }; + } + } + } module.exports = DB;