首页 文章

无法使用CosmosDb Sproc查询文档

提问于
浏览
0

我试图在我的cosmosdb集合中创建一个sproc,但是无法成功执行任何查询,如示例所示:

我根据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 回答

  • 0

    我拿了你的剧本,它在我身边运作良好 .

    enter image description here

    那么,您是否可以通过在Azure portal中使用 Query Explorer 来仔细检查集合中是否有任何文档 .

    enter image description here

相关问题