From 22eef8b27c64e0970dc96e96496b51bffc42c7c8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 5 Jul 2023 17:43:02 +0800 Subject: [PATCH] 1 --- db.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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;