我有下面的查询代码,但它使用两个主键之一获取前 3 个值。我想要的是选择最后 3 行。
仅供引用 - 我的 RowKeys 是增量添加的数字(例如 1、2、3、4、5)
var tableUri = "https://mytableuri.table.core.windows.net";
var tableService = AzureStorage.Table.createTableServiceWithSas(tableUri, sasToken);
var tableQuery = new AzureStorage.Table.TableQuery().top(3).where('PartitionKey eq ? or PartitionKey eq ?', partitionA, partitionB);
我想要类似的东西
var tableQuery = new AzureStorage.Table.TableQuery().last(3).where('PartitionKey eq ? and RowKey starts at TotalCount or PartitionKey eq ? and RowKey starts at TotalCount', partitionA, partitionB);
最佳答案
我发现这篇文章很有用 How to retrieve latest record using RowKey on SO
所以我做了什么,因为文章有一个时间戳作为行键,而我使用的是整数。
我将第一行键设置为一个很大的数字,例如 10000000,然后随着每个条目递减...
由于这些条目表示两个人之间的聊天消息,因此两个人之间永远不会命中 1000 万的大数。
现在我可以取 top(N),这将是他们之间的最新消息...
关于javascript - 如何获取 Javascript 中的最后 N 个实体以进行 Azure 存储表查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53207359/