0

Utilizing the manual editor in Azure Storage Explorer I can create the following query that returns the results I want from the Azure Table Storage:

TYPE eq 'MYTYPE' and (PartitionKey eq '1' or PartitionKey eq '2')

However, I'm not sure how to do this with the NodeJS library.

The following code:

const azure = require('azure-storage');
const svc = new azure.TableService();
var azureQuery = new azure.TableQuery().where("TYPE eq 'MYTYPE'").or("PartitionKey eq '1'").or("PartitionKey eq '2'")

Is equivalent to the query:

TYPE eq 'MYTYPE' or PartitionKey eq '1' or PartitionKey eq '2'

Likewise I can do the following:

const azure = require('azure-storage');
const svc = new azure.TableService();
var azureQuery = new azure.TableQuery().where("TYPE eq 'MYTYPE'").and("PartitionKey eq '1'").or("PartitionKey eq '2'")

But that results in the query:

 TYPE eq 'MYTYPE' and PartitionKey eq '1' or PartitionKey eq '2'

How do I do the equivalent of parenthesis from the NodeJS library?

Doug
  • 6,446
  • 9
  • 74
  • 107

1 Answers1

2

As I known, the simple way is like the code below based on my understanding for the TableQuery object.

enter image description here

var filter = "TYPE eq 'MYTYPE' and ( PartitionKey eq '1' or PartitionKey eq '2' )"
var azureQuery = new azure.TableQuery().where(filter)

It works fine.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • I don't know what I messed up when I tried that before, but I must have had some stupid typo. I tried it again this morning and it worked for me. Thanks for your help! – Doug Aug 05 '19 at 13:24