0
我是Azure DocumentDB的新手,在執行非常基本的存儲過程時遇到一些意外的行爲。存儲過程(如下所示)返回「找不到文檔」,但SELECT
語句查詢的集合中填充了許多文檔。進一步阻礙我的是,在查詢瀏覽器中運行相同的SELECT
語句會導致按預期返回單個文檔。我在這裏錯過了一些真正的基礎嗎?Azure DocumentDB存儲過程不會返回任何內容
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.");
}
只是好奇:你有一個分區集合,或單分區集合? –
是的,集合是分區的。 –