Azure DocumentDB 存储过程 returns 无
Azure DocumentDB stored procedure returns nothing
我是 Azure DocumentDB 的新手,在执行非常基本的存储过程时遇到了一些意外行为。存储过程(如下所示)正在返回 "no docs found",但是 SELECT
语句查询的集合中填充了许多文档。令我更加困惑的是,查询资源管理器中 运行 相同的 SELECT
语句导致单个文档按预期返回。我在这里错过了一些真正基本的东西吗?
function simple() {
var collection = getContext().getCollection();
// Query documents and take 1st item.
var isAccepted = collection.queryDocuments(
collection.getSelfLink(),
'SELECT TOP 1 * FROM MyCollection c',
function (err, feed, options) {
if (err) throw err;
// Check the feed and if it's empty, set the body to 'no docs found',
// Otherwise just take 1st element from the feed.
if (!feed || !feed.length) getContext().getResponse().setBody("no docs found");
else getContext().getResponse().setBody(JSON.stringify(feed[0]));
});
if (!isAccepted) throw new Error("The query wasn't accepted by the server. Try again/use continuation token between API and script.");
}
存储过程看起来不错。我 运行 这是一个包含几个文档的集合,并且 sproc returns 1 文档如预期的那样,所以我无法复制它。以下是我的推荐:
- 尝试 运行 小集合
- 更改存储过程,以防提要为空,连同 "no docs found"、return options.continuation 并查看延续标记是否为空。可能是查询被抢占了,尽管这不太可能。
谢谢!
我是 Azure DocumentDB 的新手,在执行非常基本的存储过程时遇到了一些意外行为。存储过程(如下所示)正在返回 "no docs found",但是 SELECT
语句查询的集合中填充了许多文档。令我更加困惑的是,查询资源管理器中 运行 相同的 SELECT
语句导致单个文档按预期返回。我在这里错过了一些真正基本的东西吗?
function simple() {
var collection = getContext().getCollection();
// Query documents and take 1st item.
var isAccepted = collection.queryDocuments(
collection.getSelfLink(),
'SELECT TOP 1 * FROM MyCollection c',
function (err, feed, options) {
if (err) throw err;
// Check the feed and if it's empty, set the body to 'no docs found',
// Otherwise just take 1st element from the feed.
if (!feed || !feed.length) getContext().getResponse().setBody("no docs found");
else getContext().getResponse().setBody(JSON.stringify(feed[0]));
});
if (!isAccepted) throw new Error("The query wasn't accepted by the server. Try again/use continuation token between API and script.");
}
存储过程看起来不错。我 运行 这是一个包含几个文档的集合,并且 sproc returns 1 文档如预期的那样,所以我无法复制它。以下是我的推荐:
- 尝试 运行 小集合
- 更改存储过程,以防提要为空,连同 "no docs found"、return options.continuation 并查看延续标记是否为空。可能是查询被抢占了,尽管这不太可能。
谢谢!