【问题标题】:How to pass object as parameter into CosmosDB stored procedure如何将对象作为参数传递到 CosmosDB 存储过程
【发布时间】:2018-03-09 17:19:54
【问题描述】:

如何将对象作为参数传递到 CosmosDB 存储过程中

我正在尝试测试 CosmosDB SQL 集合的存储过程,但无法将对象作为参数传递。 存储过程代码:

/*
@function
@param {object} input
*/
function sample(input) {
    var collection = getContext().getCollection();

    if (!input) throw new Error("The input is undefined or null.");

    console.log(input);
    console.log(input.a);
}

我使用的参数值{a:1}

我希望得到:

“{a:1}1”

但我得到的是:

“{a:1}未定义”

【问题讨论】:

    标签: json azure-cosmosdb


    【解决方案1】:

    在azure-cosmosdb中,传入的输入参数是string类型,而不是object类型。您可以执行 JSON.parse() 将其转换为对象并访问属性

    【讨论】:

    • 谢谢@Sajeetharan。我认为可以将对象与原始类型一起使用..
    猜你喜欢
    • 1970-01-01
    • 2020-02-21
    • 2012-07-11
    • 2012-11-23
    • 1970-01-01
    • 2014-09-29
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多