【发布时间】:2015-01-30 02:12:17
【问题描述】:
我有一个复杂的数据类型“AzureTemplate”,其中包含一个子“AzureField”列表。我已经根据this article 在服务器端实现了我的读取和插入。效果很好。
也需要更新,我将插入复制/粘贴到更新中,因此它执行相同的操作,但改用更新。所以我的更新看起来像这样:
function update(item, user, request) {
// remove complex child object, make copy first
var fields = item.fields;
if (fields) {
delete item.fields;
}
request.execute({
success: function () {
var templateId = item.id; // "foreign key"
var fieldsTable = tables.getTable('AzureFields');
if (fields) {
// update the child fields
var updateNextField = function (index) {
if (index >= fields.length) {
// done updating fields, respond to client
request.respond();
} else {
var field = fields[index];
field.templateId = templateId;
// *** THE ID LOGGED HERE LOOKS FINE ***
console.log("updating field w/ id ", field.id);
fieldsTable.update(field, {
success: function () {
updateNextField(index + 1);
}
});
}
};
// kick off the loop saving each field
updateNextField(0);
} else {
// no fields. no need to do anything else
request.respond();
}
}
});
}
打印子“字段” ID 的日志显示了一个有效的字段 ID(我在读取它们时将它们保存在客户端)。但我收到一条错误消息:
Error in script '/table/AzureTemplate.update.js'. Error: Invalid id value specified. AzureTemplate/update Tue Jan 27 2015, 10:11:31 AM
我在 AzureField.update 的顶部放置了一个 console.log(),但它从未出现过,所以它没有进入那里。此外,当我直接从客户端更新单个子“字段”时,它工作正常。所以 AzureField.update 正在工作。有任何想法吗?
【问题讨论】:
标签: node.js azure azure-mobile-services