2
votes

I'm using Azure Table Storage on CosmosDB through Node.js. I figured out a hack using greater than and less than to give startsWith functionality.

On the other hand, I still need endsWith functionality and can't find a way to make it work. It might be one of those cases where I have to pull in all partition or row keys and then do the string search myself.

I noticed Azure Table has the same query format as odata and in this document for $filter, I'm seeing an endsWith command listed: https://docs.microsoft.com/en-us/previous-versions/dynamicsnav-2016/hh169248(v=nav.90)

Is there an endsWith command available or instead, is there a way to query all the partition or row keys and do the search myself?

1
To select the PrimaryKey and RowKeys only, use: new TableQuery().select('PartitionKey', 'RowKey') - Kevin Ghadyani

1 Answers

3
votes

Is there an endsWith command available or instead, is there a way to query all the partition or row keys and do the search myself?

Unfortunately both startsWith and endsWith commands are not available in Azure Table Storage. For startsWith, I am guessing you implemented a hack similar to the solution outlined here: Can PartitionKey be queried with StartsWith?.

However no such hack is available for endsWith. One possibility though will be to store another entity where you reverse the PartitionKey (or RowKey) and then apply startsWith hack. For example, your PartitionKey is abcdef and you need to find the entities that ends with ef, you could store another entity with PartitionKey as fedcba and then to apply the startsWith hack using fe (again reversing the string you're searching for).