我正在使用Amazon Aurora Serverless 的新数据 API
是否可以在响应中获取表列名称?
例如,如果我在包含、、、、列的用户表中运行以下查询:id
first_name
last_name
email
phone
const sqlStatement = `
SELECT *
FROM user
WHERE id = :id
`;
const params = {
secretArn: <mySecretArn>,
resourceArn: <myResourceArn>,
database: <myDatabase>,
sql: sqlStatement,
parameters: [
{
name: "id",
value: {
"stringValue": 1
}
}
]
};
let res = await this.RDS.executeStatement(params)
console.log(res);
我收到了这样的回复,所以我需要猜测哪个列对应于每个值:
{
"numberOfRecordsUpdated": 0,
"records": [
[
{
"longValue": 1
},
{
"stringValue": "Nicolas"
},
{
"stringValue": "Perez"
},
{
"stringValue": "example@example.com"
},
{
"isNull": true
}
]
]
}
我想得到这样的回应:
{
id: 1,
first_name: "Nicolas",
last_name: "Perez",
email: "example@example.com",
phone: null
}
更新1
我找到了一个封装 Aurora Serverless Data API 并简化开发的npm 模块