如何在 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
,
然后,您需要在插入的文档中排除 name 属性,并在执行 SP 时提供像这样的分区键。
输出:
关于azure - 在azure服务器中执行存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55789869/