互联网上有很多关于如何使用 CompareTo 和 Azure 表存储来基本上从 C# 进行一些子字符串搜索的示例,但我找不到任何显示如何在 NodeJS 中执行此操作的内容以及我拥有的所有语法试图放在一起只是抛出各种语法或无效的查询存储异常。
谁能告诉我如何在这个网站上做与 C# 示例等效的操作,但来自 NodeJS? https://lifeportal.azurewebsites.net/azure-table-storage-searching-entities-using-query-like-substring-or-left/
string projectIdString = projectId.ToString().ToLower(); // projectId - Guid
string startQuery = projectIdString + "_"; // Our separate symbol
string endQuery = projectIdString + "`"; // Next symbol in ASCII table after "_"
Expression<Func<DynamicTableEntity, bool>> filters = (e.RowKey.CompareTo(startQuery) >= 0 && e.RowKey.CompareTo(endQuery) < 0);
CloudTable table = _storageContext.Table(Tables.Users);
bool result = await DeleteAllEntitiesInBatches(table, filters);
return result;
最明显的是:
const TABLE_NAME = 'MYTABLE';
var azure = require('azure-storage');
var tableService = azure.createTableService();
var query = new azure.TableQuery()
.where('PartitionKey eq ?', 'MYKEY').and('RowKey.compareTo(\'1-\') ge ?', 0);
tableService.queryEntities(TABLE_NAME, query, null, function(error, result, response) {
if (!error) {
// result.entries contains entities matching the query
}
});
结果是:
"An unknown function with name 'RowKey.compareTo' was found. This may also be a key lookup on a navigation property, which is not allowed."