[英]How Execute SQL Query in Azure Cosmos DB with Node.js
我正在使用以下文档向我展示如何使用 Node.JS 从 Azure Cosmos DB SQL API 帐户连接和查询数据
https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-nodejs
文档中有一段设置为查询 Azure Cosmos DB
// query to return all items
const querySpec = {
query: "SELECT * from c"
};
const { resources: results } = await container.items
.query(querySpec)
.fetchAll();
有人可以让我知道上面查询的结果显示在哪里吗?
我正在使用 Visual Studio Code 来构建代码,但是当我运行它时,我不确定结果显示在哪里。 例如,结果会显示在 Azure Cosmos DB 中吗? 在 Visual Studio Code 中? 或在哪里?
你可能已经知道我是一个 Node.JS 新手
谢谢
默认情况下,它将显示在您运行代码的控制台中。 但是我在您的代码中没有看到任何输出,也许您应该添加如下内容
if (results.length == 0) {
throw "No items found matching";
}
// Change person to your data type
const person = results[0];
console.log("The '" + person.id + "' family has lastName '" + person.lastName + "'");
console.log("The '" + person.id + "' family has " + person.children.length + " children '");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.