gpt4 book ai didi

node.js - 尝试从 Node 查询 documentDB 时请求 url 无效

转载 作者:太空宇宙 更新时间:2023-11-03 23:03:35 25 4
gpt4 key购买 nike

我正在使用文档数据库的 Node SDK,并且我能够使用以下代码成功列出我的集合中的所有文档:

collectionUrl = "dbs/dbName/colls/Membership"
this.client.readDocuments(this.collectionUrl).toArray(callback)

但是当我尝试使用以下代码查询数据时,它失败了:

querySpec = {
query: 'SELECT * FROM root r '
};
this.client.queryCollections(this.collectionUrl,this.querySpec).toArray(callback)

错误信息是:

 body:"{"code":"BadRequest","message":"Request url is invalid.\r\nActivityId: 532e52d2-7e97-41d4-8b07-a5fb19de88da"}"
code:400

知道为什么这是我需要执行的查询吗?

最佳答案

我发现您正在使用queryCollections函数来查询文档。请尝试使用:改为 this.client.queryDocuments(this.collectionUrl,this.querySpec).toArray(callback)

如果您想查询数据库中的collections,请使用databaseLink而不是collectionUrl,它应该类似于dbs/dbName.您可以引用https://github.com/Azure/azure-documentdb-node/blob/master/source/lib/documentclient.js#L813获取源代码。

请引用https://learn.microsoft.com/en-us/azure/documentdb/documentdb-nodejs-get-started#a-idqueryastep-8-query-documentdb-resources了解更多信息。

关于node.js - 尝试从 Node 查询 documentDB 时请求 url 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41608015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com