如何使用选择作为对象名称访问查询结果

How to access query result with the selection as object name

我查询了一个数据,returns得到了一个结果: [ RowDataPacket { 'COUNT(t.id)': 2 } ]

我怎样才能像计数一样访问它? 我试过 result.COUNT(t.id) 但没用。

对象的命名方式,需要这样访问:

result[0]["COUNT(t.id)"]

我宁愿在查询中使用别名明确命名列:

select count(t.id) as count_of_id
from ...