【发布时间】:2019-05-16 14:37:48
【问题描述】:
我正在尝试使用 Node.js 对我的 cosmos db 运行以下查询。
const querySpec = {
query: "SELECT * FROM Users u WHERE u.id = @email",
parameters: [
{
name: "@email",
value: "testuser@gmail.com"
}
]
};
const { result: results } = client.database(databaseId).container(containerId).items.query(querySpec).toArray();
if (results.length == 0) {
throw "No matching user";
} else if (results.length > 1) {
throw "Account found";
}
const user = results[0];
console.log(user);
但是我不断收到错误TypeError: results is undefined。该查询在数据资源管理器中运行良好。如果我使用 console.log,databaseId 和 containerId 打印我需要的值。
为什么会出现这个错误?
【问题讨论】:
标签: javascript node.js azure azure-cosmosdb azure-cosmosdb-sqlapi