如何将查询作为参数传递给 Cosmos DB 脚本资源管理器中的存储过程



我想在(https://github.com/Azure/azure-documentdb-js-server/blob/master/samples/stored-procedures/bulkDelete.js)中执行存储的过程。要执行此操作,必须将查询作为参数传递。我的查询类似于'从c 中选择值(c._self) 其中 c._ts <='+(new Date().setFullYear(new Date().getFullYear() - 1))/1000。

当我通过将上面的查询作为参数传递来执行上面的 sp(在链接中提到)时,它的抛出异常。因为SP不接受上述查询作为参数,因为它有一些函数计算。

谁能建议我如何将上述查询作为参数传递。

因为它需要"双引号",正如您的问题中所见,这些引号丢失了。

更多详情如下:

你需要的是"脚本资源管理器"

All explorers in document db are:
    "Data Explorer"
    "Document Explorer"
    "Query Explorer"
    "Script Explorer"
Click on "Script Explorer" (scroll down, it will be below "Data Explorer")
select Database on right
select Collection on right
then Stored Procedure you want to execute
then on the right there is:
    "Inputs"
        give your query like here
    "Results"
        see detailed error here

例如:

Inputs:
    SELECT c._self FROM c
Results:
    Invalid inputs.  Please ensure that the "Inputs" field contains a valid JSON value. 
Inputs:
    'SELECT c._self FROM c'     
Results:
    Invalid inputs.  Please ensure that the "Inputs" field contains a valid JSON value.
Inputs:
    "SELECT c._self FROM c"
Results:
    {"deleted":5,"continuation":false}

所以
1.前2种情况失败,因为没有引号,或者有单引号。
2. 第 3 个通过,因为有双引号。

希望有帮助。

最新更新