【问题标题】:Unable to queryDocuments using a CosmosDb Sproc无法使用 CosmosDb Sproc 查询文档
【发布时间】:2017-07-27 22:57:40
【问题描述】:

我正在尝试在我的 cosmosdb 集合中创建存储过程,但无法成功执行示例中所示的任何查询:

  1. QueryDocuments api - https://azure.github.io/azure-documentdb-js-server/Collection.html
  2. 使用 QueryDocuments 的示例 - https://github.com/Azure/azure-documentdb-js-server/blob/master/samples/stored-procedures/SimpleScript.js

我基于 SimpleScript.js 编写了自己的存储过程,看起来像

    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 创建存储过程并运行它。 这是我得到的响应体(来自回调函数中的 setBody):

{"currentCollectionSizeInMB":"documentSize=0;documentsSize=98;documentsCount=14;collectionSize=101;","maxCollectionSizeInMB":"documentSize=0;documentsSize=98;documentsCount=14;collectionSize=101;"}[]

如何成功创建这样的 Select * sproc?

谢谢

【问题讨论】:

    标签: azure-cosmosdb


    【解决方案1】:

    我拿走了你的剧本,它对我来说效果很好。

    那么,您能否使用Azure portal 中的Query Explorer 仔细检查您的集合中是否有任何文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-03
      • 2020-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多