gpt4 book ai didi

azure - 在azure服务器中执行存储过程

转载 作者:行者123 更新时间:2023-12-03 05:44:28 25 4
gpt4 key购买 nike

如何在 Azure 服务器中执行示例存储过程。

我正在使用 cosmos db 模拟器,每当我尝试执行示例 sp 时,我都会收到此错误

Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.

存储过程

function createToDoItem(itemToCreate) {
var context = getContext();
var container = context.getCollection();
console.log("success");
var itemToCreate={
"Id": null,
"UserAccountID": "1742",
"FirstName": "Sanjeev",
"LastName": "S",
"Phone": "12345678",
"Location": "",
"StreetAddress": "vcbgvbvc",
};

itemToCreate.partitionKey = "UserAccountID";

var accepted = container.createDocument(container.getSelfLink(),
itemToCreate,
function (err, itemCreated) {
if (err) throw new Error('Error test' + err.message);
context.getResponse().setBody(itemCreated.id)
});
if (!accepted) return;
}

示例存储过程也无法获得所需的结果。链接问题 here

最佳答案

Sanjeev S,基于问题消息:

Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.

它声称文档中的分区键需要与集合的分区键设置相匹配。

例如,您的集合的分区键是 /name

enter image description here

然后,您需要在插入的文档中排除 name 属性,并在执行 SP 时提供像这样的分区键。

enter image description here

输出:

enter image description here

关于azure - 在azure服务器中执行存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55789869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com