我试图在我的cosmosdb集合中创建一个sproc,但是无法成功执行任何查询,如示例所示:
-
QueryDocuments api - https://azure.github.io/azure-documentdb-js-server/Collection.html
-
使用QueryDocuments的示例 - https://github.com/Azure/azure-documentdb-js-server/blob/master/samples/stored-procedures/SimpleScript.js
我根据SimpleScript.js编写了自己的sproc
function() {
function callback(err, docs, opt)
{
if (err) getContext().getResponse().setBody(JSON.stringify(err));
else getContext().getResponse().setBody(JSON.stringify(opt).concat(JSON.stringify(docs)));
}
var collection = getContext().getCollection();
var collectionLink = collection.getSelfLink();
var x = __.queryDocuments(__.getSelfLink(),{ query: "select * from root r"},callback);
}
我正在使用DocumentDbStudio 0.72来创建sproc,然后运行它 . 这是我得到的响应体(来自回调函数中的setBody):
{"currentCollectionSizeInMB":"documentSize=0;documentsSize=98;documentsCount=14;collectionSize=101;","maxCollectionSizeInMB":"documentSize=0;documentsSize=98;documentsCount=14;collectionSize=101;"}[]
如何成功创建这样的Select * sproc?
谢谢
1 回答
我拿了你的剧本,它在我身边运作良好 .
那么,您是否可以通过在Azure portal中使用 Query Explorer 来仔细检查集合中是否有任何文档 .