【发布时间】:2020-04-20 06:21:02
【问题描述】:
我正在使用knex,我想只返回数字而不是RowDataPacket,这是我的代码:
let totalUsers = await ctx.db('user')
.join('group', 'user.id', 'group.user_id')
.where('user.first_name', 'like', '%' + firstName + '%')
.count()
.first();
console.log(totalUsers);
基本上这会返回:
RowDataPacket { 'count(*)': 1 }
我只想得到1,我该怎么做?
【问题讨论】: