【发布时间】:2020-10-22 01:19:38
【问题描述】:
Image shows the azure table如何使用 JavaScript 从 Azure 表存储中检索最新记录?
我看了这篇文章, How to retrieve latest record using RowKey or Timestamp in Azure Table storage
但我想在 Nodejs 服务器端实现相同的功能,任何建议。 到目前为止的代码,
var dt = Date().toLocaleString();
console.log("Got response: " + dt);
var entGen = azure.TableUtilities.entityGenerator;
var task = {
PartitionKey: entGen.String('ConfigData'),
RowKey: dt,
DeviceId: entGen.String(req.body.devId),
};
// Insert the entity to the table
tableSvc.insertEntity('configurationData', task, function (error, result, response) {
if (!error) {
// Entity inserted
console.log("Added the data in table successfully");
}
else{
console.log(error);
}
});
我得到以下错误,
name: 'StorageError',
message: 'The \'RowKey\' parameter of value \'11/21/2017, 8:17:24 AM\' is out of range.\nRequestId:687de370-0002-0055-09a1-62d5e1000000\nTime:2017-11-21T08:17:25.6350503Z',
code: 'OutOfRangeInput',
statusCode: 400,
requestId: '687de370-0002-0055-09a1-62d5e1000000' }
提前致谢。
【问题讨论】:
-
你能告诉我们数据是什么样子的吗?您是否已经尝试过任何方法?你有什么问题吗?
-
我试图按照我在问题中提到的文章进行操作。问题是在 C# 中,我想在 javascript 中做同样的事情
-
数据长什么样子...是列表、数组、字典、JSON文件...?
-
它有 4 列 PartitionKey、RowKey、TimeStamp 和 DeviceID - 都是字符串,我希望表中推送的数据始终将最新的实体放在顶部,以便我可以获取最新的实体轻松
-
请停止在 cmets 中提供上述详细信息。建议您编辑问题并将其包含在其中。在提供这些详细信息的同时,还包括 PartitionKey 和 RowKey 中包含的示例值。另外,当您说 JavaScript 时,您是指客户端 JavaScript 还是 Node.js。此外,请包括您迄今为止编写的任何代码以及您在该代码中遇到的问题。你不能真的指望有人为你写完整的代码。
标签: javascript azure azure-table-storage