简体   繁体   English

Azure cosmos db 存储过程,获取无效分区键错误

[英]Azure cosmos db stored procedure, getting invalid partition key error

I am getting invalid partition key error for below piece of code我收到以下代码的无效分区键错误

const {body: result} = await container.scripts.storedProcedure("bulkUpdate").execute(updateData, {partitionKey: updateData[0].upc});

Data is updateData is like below数据是 updateData 如下所示

[
   {
      "upc":"351672408367",
      "ndc":"51672408306",
      "description":"HYDROCORTISONE BUTYRATE 0.1% ONT 45 GM",
      "pack_size":"45",
      "unitMeasure":"EA"
   }
]

While defining the partition while creating the container i have defined has /upc在创建我定义的容器时定义分区时有 /upc

Where am I going wrong here?我在哪里错了?

I believe you have your parameters reversed.我相信你的参数颠倒了。 Based on the documentation , first parameter to execute method is the partition key and the next one is the input parameters to the procedure.根据documentation ,执行方法的第一个参数是分区键,下一个是过程的输入参数。

Please try something like the following (untested code):请尝试以下内容(未经测试的代码):

const {body: result} = await container.scripts.storedProcedure("bulkUpdate").execute(updateData[0].upc, [updateData]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM